Easily solve multiple record operations using DOM4J and XMLHTTP

zhaozj2021-02-08  237

/// XML Http Function // function postXmlDocument (sUri, xmlDoc) {var xmlHttp = XmlHttp.create (); var async = true; xmlHttp.open ( "POST", sUri, async); xmlHttp.setRequestHeader ( "Content- type "," text / xml "); xmlHttp.setRequestHeader (" charset "," UTF-8 "); xmlHttp.onreadystatechange = function () {if (xmlHttp.readyState == 4) postHandleCallback (xmlHttp.responseText); / / Responsexml: XmlDocument} Xmlhttp.send (XmLDoc);} Servlet End code, just need to flow in XML, then directly parsing processing

SAXReader Xmlreader = new saxreader (); InputStream in = servletActionContext.getRequest (). GetInputStream (); document = XmlReader.Read; in;

Here is the traversal of the XML document

for (Iterator i = root.elementIterator (modelName); i.hasNext ();) {Element element = (Element) i.next (); Object entityIns = instanceModel (modelName); Iterator subnodes = element.elementIterator (); while (Subnodes.hasNext ()) {ELEMENT Subnode = (Element) Subnodes.next (); DynamicPopulate (Subnode.getName (), Subnode.getText (), Entityins;

}

转载请注明原文地址:https://www.9cbs.com/read-2144.html

New Post(0)