View Single Post
  #1 (permalink)  
Old August 2nd, 2019, 04:12 PM
winkimjr2 winkimjr2 is offline
Friend of Wrox
Points: 465, Level: 7
Points: 465, Level: 7 Points: 465, Level: 7 Points: 465, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How do I create a new XML document and add elements with their value from another XML

I already have created a new xml document using VB.NET called objXmlResponseDoc but I was not able to add values for the nodes from objXmlSimpleTypeDoc xml document. Now I need help to find the correct EnumerationValue with @code that matches CourtNCIC. This CourtNCIC and be different. I already have it CourtNCIC = MN010015J. I need to look for this in the objXmlSimpleTypeDoc xml document EnumerationValue/@code. Also some nodes in objXmlSimpleTypeDoc xml document may not exist. I need to first check if a node exist before getting its value.

Here is how my new xml document (objXmlResponseDoc) looks with missing values.

Here is the objXmlSimpleTypeDoc xml document that have nodes that I want to get their values if the node exist.
<SimpleTypeCompanion enumerates="CourtLocationTextType">
    <EnumerationValue code="MN010015J">
        <Text>Emily County</Text>
        <AssociatedValue type="MNCISNodeID">
        <AssociatedValue type="CountyName">
        <AssociatedValue type="PhoneNumber">
    <EnumerationValue code="DC19DAKDC">
        <Text>Pope County</Text>
        <AssociatedValue type="MNCISNodeID">
        <AssociatedValue type="CountyName">
Here is VB.NET code that I need help with to add node values into objXmlResponseDoc xml document.
'Produce the response message
objXmlResponseDoc = New XmlDocument
objXmlMNCISData = Library.v4.Case.GetIxmlForCaseNumber(strCaseNumber, "CourtCaseHeaderGroup", False)
'CourtNCIC = MN010015J
strCourtNCIC = objXmlMNCISData.DocumentElement.SelectSingleNode("Case/Court/CourtNCIC").InnerText
'New CourtNCIC as xml element
objXmlCourtNCICElement = objXmlMNCISData.DocumentElement.SelectSingleNode("Case/Court/CourtNCIC")
'Access the CourtLocationTextType simple type. 
objXmlSimpleTypeDoc = Msc.Integration.CourtXml.Library.v4.SimpleType.GetCompanionFile("CourtLocationTextType")
'Court location
objXmlCourtLocationNode = objXmlResponseDoc.CreateElement("CourtLocation")
objXmlCourtNameElement = objXmlResponseDoc.CreateElement("CourtName")
strCourtName = objXmlCourtLocationNode.SelectSingleNode("EnumerationValue[@code=" + strCourtNCIC + "]/Test").InnerText
objXmlORINumberElement = objXmlResponseDoc.CreateElement("ORINumber")
objXmlMNCISNodeIDElement = objXmlResponseDoc.CreateElement("MNCISNodeID")
objXmlPhoneNumberElement = objXmlResponseDoc.CreateElement("PhoneNumber")
The final xml document should look like this

Last edited by winkimjr2; August 4th, 2019 at 08:58 PM.. Reason: Added details of what I am trying to do
Reply With Quote