Hi Frank ----- Original Message ----- From: "Frank Sharpless" <[EMAIL PROTECTED]> > > Hello All, > > I am having an issue with just XML (I think). How do I add values to tag > elements that might contain data that the Dom parser tries to process > instead of leaving just at text? > > Example: > > <TESTELEMENT>this is the value containing the <data></TESTELEMENT> > > I would like the value of TESTELEMENT to equal 'to be this is the value > containing the <data>'. Instead the Dom parser kicks this out because the > </data> element is missing. I am also having problems with ":" and some > other special characters.
XML has various special characters; so certain things need to be escaped properly. XML is a text encoding format afterall. Maybe reading the XML 1.0 spec might help or Elliotte's new book... http://www.cafeconleche.org/books/xmljava/chapters/ch01.html Anyways to include XML markup as text then you need to encode the markup by escaping it... <TESTELEMENT>this is the value containing the <data></TESTELEMENT> Or if you want to preserve the markup then just use the dom4j API... Element testElement = document.addElement( "TESTELEMENT" ); testElement.addText( "this is the value containing the " ); testElement.addElement( "data" ); You probably will have some trouble using ":" in element names. This is because ":" is used for namespaces. e.g. in a SOAP document you might namespace the SOAP element as... <env:Envelope xmlns:env="http://www.w3.org/2001/12/soap-envelope"> <env:Header> <n:alertcontrol xmlns:n="http://example.org/alertcontrol"> <n:priority>1</n:priority> <n:expires>2001-06-22T14:00:00-05:00</n:expires> </n:alertcontrol> </env:Header> <env:Body> <m:alert xmlns:m="http://example.org/alert"> <m:msg>Pick up Mary at school at 2pm</m:msg> </m:alert> </env:Body> </env:Envelope> So I'd basically refrain from using ":" in element names or try using namespaces instead James _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user
