Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code> void TraverseNode(string path) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(new StreamReader(path, System.Text.Encoding.UTF8)); XmlNodeList _nodeList = xmlDocument.SelectNodes("//session"); string strxml = ""; string completexml = ""; for (int inode = 0; inode &lt; _nodeList.Count; inode++) { if(inode==0) strxml = formatxml(_nodeList[inode].OuterXml).ChildNodes[0].ChildNodes[0].OuterXml; else strxml = formatxml("&lt;session&gt;" + _nodeList[inode].OuterXml + "&lt;/session&gt;").ChildNodes[0].ChildNodes[0].OuterXml; completexml += strxml; strxml = ""; } XmlDocument newxml = new XmlDocument(); newxml.LoadXml("&lt;session&gt;" + completexml + "&lt;/session&gt;"); newxml.Save(@"C:\Working\Teradata\ssis\out_18.xml"); } XmlDocument formatxml(string xml) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(xml); XmlNode nodeListOtherInterest = xmlDocument.SelectSingleNode("//session/data/account/additionalOtherInterest/address"); XmlNode acAddress = xmlDocument.SelectSingleNode("//session/data/account/address"); XmlNode locationaddress = xmlDocument.SelectSingleNode("//session/data/account/location/address"); XmlNode lineaddress = xmlDocument.SelectSingleNode("//session/data/policy/line/address"); string strotherinterest = ""; string stracAddress = ""; string strlocationaddress = ""; string strlineaddress = ""; string straddressess=""; XmlNodeList statecodes; statecodes = xmlDocument.SelectNodes("//session/data/policy/line/linestate/linestateterm/coverage/statCode"); for (int i = 0; i &lt; statecodes.Count; i++) { if(statecodes[i].InnerText=="0") statecodes[i].ParentNode.RemoveChild(statecodes[i]); } if (xmlDocument.SelectSingleNode("//session/data/account/additionalOtherInterest/address") != null) { strotherinterest = "&lt;address_otherinterest&gt;" + nodeListOtherInterest.InnerXml + "&lt;/address_otherinterest&gt;"; nodeListOtherInterest.ParentNode.RemoveChild(nodeListOtherInterest); } if (xmlDocument.SelectSingleNode("//session/data/account/address") != null) { stracAddress = "&lt;address_Account&gt;" + acAddress.InnerXml + "&lt;/address_Account&gt;"; acAddress.ParentNode.RemoveChild(acAddress); } if (xmlDocument.SelectSingleNode("//session/data/account/location/address") != null) { strlocationaddress = "&lt;address_location&gt;" + locationaddress.InnerXml + "&lt;/address_location&gt;"; locationaddress.ParentNode.RemoveChild(locationaddress); } if (xmlDocument.SelectSingleNode("//session/data/policy/line/address") != null) { strlineaddress = "&lt;address_line&gt;" + lineaddress.InnerXml + "&lt;/address_line&gt;"; lineaddress.ParentNode.RemoveChild(lineaddress); } straddressess= "&lt;addressess&gt;"+strotherinterest +stracAddress+strlocationaddress+strlineaddress + "&lt;/addressess&gt;"; XmlDocument address = new XmlDocument(); address.LoadXml(straddressess); XPathNavigator pnav = xmlDocument.CreateNavigator(); pnav.MoveToChild("session", ""); pnav.MoveToChild("session",""); pnav.AppendChild(straddressess); return xmlDocument; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload