To convert a string to an XML object on the Java end, use incluenthelper. parsetext (xmlreturn). getrootelement ();
In JS, there are also ways to convert strings into XML objects. You can use the following functions:
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 ") } |
It is more convenient to read files on the JS end.
VaR xmldoc = new activexobject ("msxml2.domdocument. 3.0 "); Xmldoc. async = false; Xmldoc. Load ("file path "); |
XML operations are also very simple. If JDOM or dom4j is used, the operations are quite convenient.
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; } |
The method for obtaining node values and attribute values is different.
Permanent address: http://www.livebaby.cn/blog/u/meil/archives/2007/2637.html