Turn: http://www.cnblogs.com/dujun0618/articles/747095.html
// Read the component information from the material group according to the part number
Function readranliao (PID, XPath)
{
VaR curnodeparent = xdocument. Dom. selectsinglenode (XPath). parentnode;
VaR curnodes = xdocument. Dom. selectnodes (XPath );
VaR curpcount = xdocument. Dom. selectsinglenode ("/My: Wenzhou Torch/My: Save the current production quantity"). text;
Curnodes. removeall ();
VaR pidnodes = xdocument. getdom ("material composition-single table "). selectnodes ("/DFS: myfields/DFS: datafields/TNS: getdataresponse/TNS: getdataresult/My: Wenzhou Torch/My: Template structure [My: no. = '"+ PID +"']/My: Group/My: group ");
VaR pidnodeslength, xmlstr = "", comment STR = "";
Pidnodeslength = pidnodes. length;
// Xdocument. UI. Alert (pidnodeslength );
If (pidnodeslength> 0)
{
While (pidnodeslength> 0)
{
VaR sonpidnode = pidnodes. nextnode ();
Xmlstr + = sonpidnode. xml;
Pidnodeslength --;
}
// Data Source
Xmlstr = '<? XML version = "1.0" encoding = "gb2312"?> <Root> '+ xmlstr + "</root> ";
// Xdocument. UI. Alert (xmlstr );
// Convert the style
Required STR + = '<? XML version = "1.0" encoding = "gb2312"?> <XSL: stylesheet version = "1.0" xmlns: XSL = "http://www.w3.org/1999/XSL/Transform" xmlns: My = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-05-23T07:44:28" xmlns: msxsl = "urn: Schemas-Microsoft-com: XSLT" xmlns: fn = "usercode"> ';
Required STR + = '<msxsl: script language = "JavaScript" implements-Prefix = "FN"> ';
Repeated STR + = 'function getallcount (count, pcount) {return parsefloat (count) * pcount ;}</msxsl: SCRIPT> ';
Required STR + = '<XSL: template match = "/"> <my: Result> <XSL: For-each select = "root/My: composite group"> <my: raw material information group> ';
Required STR + = '<my: raw material serial number> <XSL: value-of select = "position ()"/> </My: raw material serial number> ';
Strong STR + = '<my: Part> <XSL: value-of select = "My: Part 1"/> </My: Part> ';
Required STR + = '<my: raw material Name> <XSL: value-of select = "My: Name 1"/> </My: raw material Name> ';
Required STR + = '<my: raw material specification> <XSL: value-of select = "My: Specification 1"/> </My: raw material specification> ';
Explain STR + = '<my: raw material remarks> <XSL: value-of select = "My: remarks 1"/> </My: raw material remarks> ';
Required STR + = '<my: raw material no.> <XSL: value-of select = "My: No. 1"/> </My: raw material no.> ';
Required STR + = '<my: Raw Material Unit> <XSL: value-of select = "My: Unit 1"/> </My: Raw Material Unit> ';
Explain STR + = '<my: raw material quantity> <XSL: value-of select = "FN: getallcount (sum (My: quantity 1),' + curpcount + ') "/> </My: raw material quantity> ';
Strong STR + = '<my: production and outsourcing> 1 </My: production and outsourcing> ';
Explain STR + = '<my: calculation formula> </My: calculation formula> ';
Required STR + = '</My: raw material information group> </XSL: For-each> </My: Result> </XSL: Template> ';
Repeated STR + = '</XSL: stylesheet> ';
// Xdocument. UI. Alert (reverse Str );
VaR xmldom, writable Dom, transdom;
Xmldom = xdocument. createdom ();
Xmldom. loadxml (xmlstr );
// Xdocument. UI. Alert (xmldom. XML );
Export dom = xdocument. createdom ();
Using Dom. loadxml (using STR );
// Xdocument. UI. Alert (export Dom. XML );
Transdom = xdocument. createdom ();
Transdom. loadxml (xmldom. transformnode (writable DOM ));
Transdom. setproperty ("selectionnamespaces", 'xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: My = "http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-05-23T07:44:28" xmlns: XD = "http://schemas.microsoft.com/office/infopath/2003 "');
// Xdocument.ui.alert(transdom.doc umentelement. XML );
VaR Childs = transdom.doc umentelement. selectnodes ("/My: result/My: raw material information group ");
VaR childslength = Childs. length;
While (childslength> 0)
{
VaR sonchild = Childs. nextnode ();
Curnodeparent. appendchild (sonchild );
Childslength --;
}
}
}