XML Nodes - Copying

J

JJ

I need to basically copy an entire XML document to another XML document.

The first needs to be an exact copy of the second, and I need to do it a
node at a time as I am omitting certain nodes that have certain attributes.

Whats the best way of doing this?

JJ
 
M

Martin Honnen

JJ said:
I need to basically copy an entire XML document to another XML document.

The first needs to be an exact copy of the second, and I need to do it a
node at a time as I am omitting certain nodes that have certain attributes.

An exact copy omits certain nodes?
Whats the best way of doing this?

Sounds like an easy job for an XSLT stylesheet with two templates, one
the identity transformation, the second for those elements to be omitted
e.g.

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>

<xsl:template match="element-name[@attribute-name]" />

You can run XSLT transformations in .NET 1.x with XslTransform, in .NET
2.x with XslCompiledTransform.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top