Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - xerces serializing < [Thread Next] Re: xerces serializing <To: NULL Date: 11/3/2005 12:56:00 PM shaun roe wrote: > I have xml encoded in a string with elements like <myElement/> > > e.g > > <codeFragment> <myElement>some text</myElement> > </codeFragment> > > I parse this in Xerces and I can see it has done the correct thing, > but now I want to serialize the output so it **looks** like valid xml, > i.e. > <codeFragment> <myElement>someText</myElement> </codeFragment> You can only talk about "valid" XML if you have a DTD or schema. As for those snippets, both are "well-formed" XML, obviously the first one is one elements with some text as a child node while the second is an element with text and an element as child nodes. > this doesnt happen; instead I get > > <codeFragment> <myElement>someText </myElement> </codeFragment> Text has to be serialized with '<' escaped as <, otherwise it is not a proper serialization. > I dont want to change the DOM model, I just want the serializer to > output text which has the "<" in it. Is there some way of stopping it > escaping the "<" ? If you first choose to escape some XML markup as text in an XML document you can't complain that the XML tools then treat that as text. Of course with the DOM you can read out the text contents of an element and then feed that to a new DOM parser to parse it as XML. Or you would need to write your own serializer traversing a DOM tree and not escaping text contents or perhaps not escaping text contents in certain elements. -- Martin Honnen http://JavaScript.FAQTs.com/ | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
