I am unable to check for CDATA in XML and read it using XMLEventReader.
The following is the sample:
<name>HEADERS</name>
<data>
<![CDATA[ Sat Nov 19 18:50:15 2016 (1672822)
]]>
<![CDATA[Sat, 19 Nov 2016 18:50:14 -0800 (PST)
]]>
</data>
The XMLEventReader of Stax api which i am using is as follows:
while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
if (event.isCharacters()) {
System.out.println(event.asCharacters().isCData());
System.out.println(event.asCharacters().getData());
}
}
So,when I read the data tag for characters, I get false for event.asCharacters().isCData(). Would like to know how to check for CDATA in EventReader and get the CDATA as well.
Use the following pattern:
Complete sample:
With /path/toYour/sample/file.xml
Gives: