Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 2nd, 2019, 04:12 PM
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.

Code:
<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.
Code:
<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>
Here is VB.NET code that I need help with to add node values into objXmlResponseDoc xml document.
Code:
'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)
The final xml document should look like this
<GetCaseInformationResponseMessage>
<CourtLocation>
<CourtName>Emily</CourtName>
<ORINumber>MN010015J</ORINumber>
<MNCISNodeID>111</MNCISNodeID>
<PhoneNumber>724-820-7123</PhoneNumber>
</CourtLocation>
</GetCaseInformationResponseMessage>

Last edited by winkimjr2; August 4th, 2019 at 08:58 PM.. Reason: Added details of what I am trying to do
Reply With Quote
  #2 (permalink)  
Old August 5th, 2019, 05:03 PM
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 Delete question

I no longer need help with this one
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding an elements to existing xml document crashbandicoot BOOK: Beginning PHP 5.3 0 January 12th, 2012 05:51 PM
XSLT excluding elements based on an external document ashcarrot XSLT 5 January 12th, 2009 01:05 PM
accessing elements using document() function geoGregory3 XSLT 2 February 28th, 2008 07:39 PM
Comparing elements in an XML document dlorenz XSLT 0 August 7th, 2007 05:28 PM
convert elements based on place in document jefke XSLT 2 May 17th, 2004 05:32 AM



All times are GMT -4. The time now is 09:18 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.