Easily solve multiple record operations using DOM4J and XMLHTTP

xiaoxiao2021-03-06  53

/// 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.getText (), Subnode.getText (), Entityins);}

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

New Post(0)