You can convert a string to an XML Object in Java. Use Incluenthelper. parsetext (xmlreturn). getrootelement ();
In JS, there are also ways to convert strings into XML objects. You can use the following Function
The following is a reference clip: Function createxml (STR ){ If (document. All ){ VaR xmldom = new activexobject ("Microsoft. xmldom ") Xmldom. loadxml (STR) Return xmldom } Else Return new domparser (). parsefromstring (STR, "text/XML ") } |
If you want to read File It is more convenient.
The following is a reference clip: VaR xmldoc = new activexobject ("msxml2.domdocument. 3.0 "); Xmldoc. async = false; Xmldoc. Load ("file path "); |
As for XML operations Simple If JDOM or dom4j is used, the operation is quite convenient.
The following is a reference clip: VaR domxml = createxml (HTTP. responsetext ); VaR code = domxml. getelementsbytagname ("Code "); If (code. Item (0). Text = "100 "){ VaR parameter = domxml. getelementsbytagname ("parameter "); Identifier = parameter. Item (0). Attributes. getnameditem ("value"). value; } |
Obtain the node value and attribute value Method Different.