ksoap2 equivalent to didStart/didEndElement?
my question for today is that i'm curious about if there is a close relative and/or equivalence in java
using the ksoap2
-library to parse element-by-elements.
In objective-c
for example:
public void didEndElement(args....){
if occurring element is thisElement
//do something with the value in the element
}
public 开发者_如何学Cvoid didStartElement(args....){
if occurring element is thisElement
//do something with the value in the element
}
While in java
SoapObject foo = (SoapObject)bar.getProperty(enum);
aString = foo.getProperty(enum);
aNotherString = foo.getProperty(anotherEnum);
So, basically, what we want to do is,
improvised java
syntax:
if(currentElement == "myElement")
aVar = valueInElement;
// or
a[1] = valueInElement;
I know that this might a be a lot to ask for, but any pointers or hints to where i can attain any information about this, if it is possible at all.
I think the SAX Parser can help you with that. As in this link: http://www.androidpeople.com/android-xml-parsing-tutorial-using-saxparser
There, a class named MyXmlHandler is created. This one extends the DefaultHandler class and allows you to override the startElement and endElement methods.
@Override
public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {}
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {}
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {}
There are a lot of tutorials spread out across the internet wich show you how to use this method. The formatting in the link is quite bad, there's gotta be a better one to find.
精彩评论