<![CDATA[ url ]]>
I have a problem right now,
I need to parse an XML but some "values" of several tags has the <![CDATA[]]>
. I'm working right now on how can I parse those values. I tried a lot of things and I'm still not sure how can I do something like that.
public class myParser extends DefaultHandler
{
public void startEl开发者_运维问答ement(String uri, String localName, String qName, Attributes attributes)throws SAXException
{}
public void endElement(String uri, String localName, String qName) throws SAXException
{}
public void characters(char[] ch, int start, int length) throws SAXException
{}
}
This is the structure that im working on it.
And I'm calling my parse like:
MyParser parser = new MyParser();
Xml.parse(xml, parser);
You don't need to parse them. CDATA sections are a standard part of XML syntax, and are used to encapsulate string data that would otherwise need XML-encoding.
Just parse the document as you would any other, and you'll find that the CDATA sections are automatically decoded for you.
In the case of your SAX example, the data will be passed to you via the characters
method.
精彩评论