10-11-2011 10:11 AM
You code looks a little confused to me. have you reviewed any of the online documentation on using a SAX parser?
Anyway, your start element should be called, And generally if I am looking for a tag, I look for it in there, comparing the localname. Assuming I have fond the localname I want, then I go through the attributes, much as you have done. Again I typically use the local name, and when I have fond the attribute I want, I process the value.
Now the bad news here is that the XML you actually want is packaged inside some XML. So the processing I think you have to do is
a) Invoke a parser on the whole XML,
b) Once you have found your element (looking for "description" in startElement), set a flag, turn flag off if not your element
c) In characters() check the flag, and when you find the flag set, extract those characters.
d) Now you have the characters you have to parse, so you need to start another XML parser (actually I would not do this recursively, I would save the characters and let the first parser complete. But you can do it recursively if you wish.
e) In this XML parser you have to look for the img element, and then use code like we have already discussed to find the attribute you want.
If this is all the data you are getting I would be seriously tempted to just use indexOf to find the img=, then extract the URL from between the following quotation marks. Having to run two parsers to find this out seems like over kill. But my suggestion is grubby.....
10-12-2011 04:39 AM
No, it doesn't work like that.
With the SAX parser you get notified as it parses the String, so it has to parse it.
If you use the DOM parser, then you can use something like that to get the CDATA for <description>, then you will have to call the DOM parser again to extract the <img> tag and from there get the attribute.
10-12-2011 08:21 AM
10-13-2011 03:35 AM
10-13-2011 05:14 AM
10-13-2011 05:32 AM