How to parse a XML having data included in <![CDATA[---]...
how can we parse the xml and get the data included in CDATA
???
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- Illegal to have multiple roots (start tag in epilo
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
here
r.get().getResponseBody()
is the response body( http://www.java2s.com/Code/Java/XML/GetcharacterdataCDATAfromxmldocument.htm )
CDATA
just says that the included data should not be escaped. So, just take the tag text. XML parser should return the clear data withoutCDATA
.Since all previous answers are using a DOM based approach. This is how to parse CDATA with a stream based approach using STAX.
Use the following pattern:
Complete sample:
With /path/toYour/sample/file.xml
Gives: