Is there a way to get CDATA tag content from the following xml tag (category):
<category>
<h1>Some data</h1>
<![CDATA[<br> some data ...]]>
<h1>Some data</h1>
<![CDATA[<br> more data ...]]>
</category>
Could somehow characters method get only content inside category tag but outside h1 tags?
Thanks
Override startCDATA()
and endCDATA()
methods in DefaultHandler2 implementation.
DefaultHandler2 handler2 = new DefaultHandler2() { /* ... */ }
Configure XMLReader
SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); XMLReader xmlReader = saxParser.getXMLReader(); xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler2);
Start parsing
saxParser.parse( /* input source */, handler2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.