Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy nodeset from one document to the other

Status
Not open for further replies.

Gert74

Technical User
Jan 26, 2001
48
0
0
NL
Hi,
I'm working with two xml-documents: a source-document and a work-document. Whenever a new node is added to the source it should be copied from the source to the workdocument. I wondered if this could be achieved at once, instead of creating each element at once.

Confused? Here's an example. I want to append The latest poll-element from the source (including all child-elements and data) to the polls-element of the work-dcoument.

I already have a objPollNode which contains the complete poll-element to be copied.
Code:
' Transform SourceXML with strPollXSL to get the requested poll
strOutPutXML = objBronXML.TransformNode(objPollXSL)
objPollNode.LoadXML(strOutPutXML)
Source:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<polls>
	<poll id="tcm:17-74467" type="MultipleChoice" datestart="2005-10-27T15:04:00" dateend="2005-11-11T15:04:00">
		<title>First Poll</title>
		<question>This is the first poll</question>
		<answer>True</answer>
		<answer>False</answer>
		<answer>I don't care</answer>
	</poll>

'Red part should be copied. This is stored in strOutPutXML and objPollNode
[COLOR=red]
	<poll id="tcm:17-74468" type="Open" datestart="2005-11-11T15:09:00" dateend="2005-11-18T15:10:00">
		<title>New name intranet</title>
		<question>Come up with a new name for our intranet.</question>
	</poll>
[/color]
</polls>

Work: (target-xml)
Code:
<?xml version="1.0" encoding="utf-8" ?>
<polls>
	<poll id="tcm:17-74467" type="MultipleChoice" datestart="2005-10-27T15:04:00" dateend="2005-11-11T15:04:00">
		<title>First Poll</title>
		<question>This is the first poll</question>
		<answer>True</answer>
		<answer>False</answer>
		<answer>I don't care</answer>
	</poll>
</polls>

Gert
 
Don't really understand what your problem is.

Jon

"I don't regret this, but I both rue and lament it.
 
What I want is to copy the part in red to another xml-file (target-xml).

I created two objects:
1. objBronXML - Which contains the source XML
2. objWerkXML - Which contains the target XML

Then I created a string:
strOutPutXML - Which contains the part in red (See above)

Maybe the rest of my actions are more confusing than helpful, so I leave them out. Bottomline: I want the red part (strOutPutXML) to be added to objWerkXML in the most efficient way. Preferably at once and not by creating each element one by one.

Gert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top