Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This question is a simpler version of a previous question.

I want to create a new xml document named objXmlResponseDoc and add two elements from an existing xml document named objXmlSimpleTypeDoc

Here is the xml document I want to get the values from. It is named objXmlSimpleTypeDoc

XML
<SimpleTypeCompanion>
	<EnumerationValue code="DC19DAKDC">
		<Text>Dakota County</Text>
		<AssociatedValue type="MNCISNodeID">
			<Text>112</Text>
		</AssociatedValue>
	</EnumerationValue>
</SimpleTypeCompanion>


Here is the new xml document I want to create

XML
<GetCaseInformationResponseMessage>
	<CourtLocation>
		<CourtName>Dakota County</CourtName>
		<MNCISNodeID>112</MNCISNodeID>
	</CourtLocation>
</GetCaseInformationResponseMessage>


What I have tried:

VB
'Produce the response message
objXmlResponseDoc = New XmlDocument
objXmlResponseDoc.AppendChild(objXmlResponseDoc.CreateElement("GetCaseInformationResponseMessage"))

'Court location
objXmlCourtLocationNode = objXmlResponseDoc.CreateElement("CourtLocation")
objXmlResponseDoc.DocumentElement.AppendChild(objXmlCourtLocationNode)

'CourtName    
objXmlCourtLocationNode.AppendChild(objXmlResponseDoc.CreateElement("CourtName"))
objXmlResponseDoc.ImportNode(objXmlSimpleTypeDoc.SelectSingleNode("EnumerationValue/Text"))
Posted
Updated 12-Aug-19 2:28am
v2
Comments
MadMyche 2-Aug-19 14:29pm    
If you want my opinion... I would think about creating a Class for each of these document types, using XML serialization tools, and overload a construct to map values from one class to the other

1 solution

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