Click here to Skip to main content
14,268,557 members
Rate this:
Please Sign up or sign in to vote.
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

<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

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


What I have tried:

'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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100