James' Blog

James’ personal blog
Previous Post:  

XML parsing trouble with & (aka ampersand, &)

I have been working with XML parsing recently using the StAX  (why use StAX?).  However, I ran into an issue with the & (ampersand) since it is a reserved character in xml and needs to be escaped.   But when the & was escaped the parser would fire multiple events, 1) text before the &, 2) the &, 3) text after the &.  This was a bit hard to integrate with, so instead of putting a & in the xml file I just replaced it with a different character and did a search and replace once the data was parsed.  This strategy saved me quite a bit of work.

Tags: ,

Posted in JAVA 1 year, 2 months ago at 3:36 pm.

Add a comment

Comments are closed.