To get the value of inside tag using pull parser
I am having one XML file and I want to parse only useful data from it..
My XML is like this:
<seller>
<id type="integer">101</id>
<name>James</name>
<bidder>
开发者_如何转开发 <id type="integer">1978271</id>
<name>SCJP</name>
</bidder>
</seller>
<seller>
<id type="integer">102</id>
<name>Joseph</name>
<bidder>
<id type="integer">1978272</id>
<name>MCST</name>
</bidder>
</seller>
MY Problem: I have a code for that but it returns both the id of seller and bidder..i want only seller id and most important without use of flag set..
please.Is anyone know that things help me as early as possible..
http://www.ibm.com/developerworks/opensource/library/x-android/
Scroll down to the SAX Parser. What you should know is that you need to put the characters in a buffer like they do in the example:
@Override
public void characters(char[] ch, int start, int length)
throws SAXException {
super.characters(ch, start, length);
builder.append(ch, start, length);
}
And at the closing tag take care of the builder to be able to fetch the id. Since they have the same name tag you need to have some booleans which tells you were in the parsing you are.
精彩评论