Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
XML
<GetCaseInformationResponseMessage>
    <CourtLocation>
        <CourtName/>
        <ORINumber/>
        <MNCISNodeID/>
        <PhoneNumber/>
    </CourtLocation>
</GetCaseInformationResponseMessage>


Here is the objXmlSimpleTypeDoc xml document that have nodes that I want to get their values if the node exist.
XML
<SimpleTypeCompanion enumerates="CourtLocationTextType">
    <EnumerationValue code="MN010015J">
        <Text>Emily County</Text>
        <AssociatedValue type="MNCISNodeID">
            <Text>111</Text>
        </AssociatedValue>
        <AssociatedValue type="CountyName">
            <Text>Emily</Text>
        </AssociatedValue>
        <AssociatedValue type="PhoneNumber">
            <Text>724-820-7123</Text>
        </AssociatedValue>
    </EnumerationValue>
    <EnumerationValue code="DC19DAKDC">
        <Text>Pope County</Text>
        <AssociatedValue type="MNCISNodeID">
            <Text>112</Text>
        </AssociatedValue>
        <AssociatedValue type="CountyName">
            <Text>Pope</Text>
        </AssociatedValue>
    </EnumerationValue>
</SimpleTypeCompanion>


The final xml should look like this
XML
<GetCaseInformationResponseMessage>
    <CourtLocation>
        <CourtName>Emily</CourtName>
        <ORINumber>MN010015J</ORINumber>
        <MNCISNodeID>111</MNCISNodeID>
        <PhoneNumber>724-820-7123</PhoneNumber>
    </CourtLocation>
</GetCaseInformationResponseMessage>


What I have tried:

Here is VB.NET code that I need help with to add node values into objXmlResponseDoc xml document.
VB
'Produce the response message
objXmlResponseDoc = New XmlDocument
objXmlResponseDoc.AppendChild(objXmlResponseDoc.CreateElement("GetCaseInformationResponseMessage"))
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")
objXmlResponseDoc.DocumentElement.AppendChild(objXmlCourtLocationNode)
'CourtName
objXmlCourtNameElement = objXmlResponseDoc.CreateElement("CourtName")
strCourtName = objXmlCourtLocationNode.SelectSingleNode("EnumerationValue[@code=" + strCourtNCIC + "]/Test").InnerText
objXmlCourtLocationNode.AppendChild(objXmlCourtNameElement)
'ORINumber
objXmlORINumberElement = objXmlResponseDoc.CreateElement("ORINumber")
objXmlCourtLocationNode.AppendChild(objXmlORINumberElement)
'MNCISNode ID
objXmlMNCISNodeIDElement = objXmlResponseDoc.CreateElement("MNCISNodeID")
objXmlCourtLocationNode.AppendChild(objXmlMNCISNodeIDElement)
'PhoneNumber 
objXmlPhoneNumberElement = objXmlResponseDoc.CreateElement("PhoneNumber")
objXmlCourtLocationNode.AppendChild(objXmlPhoneNumberElement)
Posted
Updated 6-Aug-19 4:37am
v2
Comments
[no name] 4-Aug-19 16:15pm    
Repeating the same question and expecting a different answer?
Member 11403304 4-Aug-19 21:00pm    
Someone told me to post a new question with these details instead of editing the previous question. I apologize if this is not acceptable.
Patrice T 5-Aug-19 0:11am    
Use Improve question to update a question.
Member 11403304 5-Aug-19 7:32am    
Okay I have done that with this question by adding expected xml result.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900