For XML to be equivalent, things like namespace prefixes, whitespace*, etc can be different. With Strings, this is not the case. For example: <foo xmlns="http://foobaz" /> and <baz:foo xmlns:baz="http://foobaz" /> Are equivalent in XML.
If you are hoping to do an == check using the above with strings it will ALWAYS fail with String.equals. Why not try XMLObject.[compareTo|compareValue|valueEquals] ? -jacobd On Mon, Sep 15, 2008 at 7:14 AM, Nicolai Odum <[EMAIL PROTECTED]> wrote: > > Sorry - but no good > > From the javadoc > > *toString* > *String* <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html> * > toString*() > Returns an XML string for this XML object. > > The string is pretty-printed. If you want a non-pretty-printed string, or > if you want to control options precisely, use the xmlText() methods. > > /Nicolai > > CSC • This is a PRIVATE message. If you are not the intended recipient, > please delete without copying and kindly advise us by e-mail of the mistake > in delivery. NOTE: Regardless of content, this e-mail shall not operate to > bind CSC to any order or other contract unless pursuant to explicit written > agreement or government initiative expressly permitting the use of e-mail > for such purpose • CSC Danmark A/S • Registered Office: Retortvej 8, DK > -1780 Copenhagen V , Denmark • Registered in Denmark No: 15231599 > > > > *"Andrew Mansfield" <[EMAIL PROTECTED]>* > > 15-09-2008 16:13 > Please respond to > [email protected] > > To > <[email protected]> cc > Subject > RE: Very simple question (I think) > > > > > try parse.toString(); > > ------------------------------ > *From:* Nicolai Odum [mailto:[EMAIL PROTECTED] * > Sent:* 15 September 2008 15:09* > To:* [EMAIL PROTECTED] > Subject:* RE: Very simple question (I think) > > > I will try again :-) > > Sorry for my pore english skills. > > When I say invalid i mean that the generated hash value no longer is > valid...I can work with the xml beans structure but I need acces to the > untouched, native, raw xml string that I used as a argument to the factory. > > XmlObject parse = XmlObject.Factory.parse(*xml*); > > > /Nicolai > > CSC • This is a PRIVATE message. If you are not the intended recipient, > please delete without copying and kindly advise us by e-mail of the mistake > in delivery. NOTE: Regardless of content, this e-mail shall not operate to > bind CSC to any order or other contract unless pursuant to explicit written > agreement or government initiative expressly permitting the use of e-mail > for such purpose • CSC Danmark A/S • Registered Office: Retortvej 8, DK > -1780 Copenhagen V , Denmark • Registered in Denmark No: 15231599 > > > *"Andrew Mansfield" <[EMAIL PROTECTED]>* > > 15-09-2008 15:58 > Please respond to > [email protected] > > > To > <[email protected]> cc > Subject > RE: Very simple question (I think) > > > > > > > I just ran the following Junit test with no problems... > > > *public* *void* test() *throws* XmlException, IOException{ > > String xmltext = *new* String( > "<test><element1>testvalue</element1></test>"); > > XmlObject xmlObject = > XmlObject.Factory.*parse*(*new*ByteArrayInputStream(xmltext.getBytes())); > > Node rootnode = xmlObject.getDomNode().getFirstChild(); > > *assertEquals*("test",rootnode.getNodeName()); > > } > > > > ------------------------------ > *From:* Nicolai Odum [mailto:[EMAIL PROTECTED] * > Sent:* 15 September 2008 14:41* > To:* [EMAIL PROTECTED] > Subject:* RE: Very simple question (I think) > > > Sorry bad example > > It's was just suppose to be psudo code > > String xml = "big xml document"; > > I have tried it with many big valid xml documents - without luck. > > /Nicolai > > *"Andrew Mansfield" <[EMAIL PROTECTED]>* > > 15-09-2008 15:36 > Please respond to > [email protected] > > > To > <[email protected]> cc > Subject > RE: Very simple question (I think) > > > > > > > > > I think you need to parse a valid source document first. Then you can get > access to the underlying XmlObject. > > Regards, > > ------------------------------ > *From:* Nicolai Odum [mailto:[EMAIL PROTECTED] * > Sent:* 15 September 2008 14:32* > To:* [EMAIL PROTECTED] > Subject:* Very simple question (I think) > > > Hello > > On > *xmlbeans.apache.org*<http://xmlbeans.apache.org/docs/2.0.0/guide/conGettingStartedwithXMLBeans.html>it > says that XMLBeans provide > > <quote> > It provides a familiar Java object-based view of XML data without losing > access to the original, native XML structure > </quote> > > I am using XMLBeans on a xml structure that is signed with a hash value so > *nothing* must change before the xml is invalid. > > The question is: *HOW* do i get access to the original, native XML > structure. > > because this doesn't work > > String xml = "big xml document"; > XmlObject parse = XmlObject.Factory.parse(xml); > String newXml = parse.xmlText(); > > if (xml.equals(newXml) > System.out.println("jubii"); > else > System.out.println("damn"); > > > > Please help :-) > > Cheers > > Nicolai > > ------------------------------ > > This email with all information contained herein or attached hereto may > contain confidential and/or privileged information intended for the > addressee(s) only. If you have received this email in error, please contact > the sender and immediately delete this email in its entirety and any > attachments thereto. > (W1) > > > > ------------------------------ > > This email with all information contained herein or attached hereto may > contain confidential and/or privileged information intended for the > addressee(s) only. If you have received this email in error, please contact > the sender and immediately delete this email in its entirety and any > attachments thereto. > (W1) > > > > ------------------------------ > > This email with all information contained herein or attached hereto may > contain confidential and/or privileged information intended for the > addressee(s) only. If you have received this email in error, please contact > the sender and immediately delete this email in its entirety and any > attachments thereto. > (W1) > > >

