How to copy specific nodes from one XML document to another using xls

  • I have a large XML document that I need to fitter into a smaller xml document for use in a SQL2008 DB. A simple representation if the input XML is something like:

    <MyXML>

    <NodeA>

    <NodeA1>

    <ElementA1_1/>

    <ElementA1_2/>

    ...

    </NodeA1>

    </NodeA>

    <NodeB>

    <NodeB1>

    <NodeB1a>

    <ElementB1a_1/>

    <ElementB1a_2/>

    ...

    </NodeB1a>

    </NodeB1>

    <NodeB2>

    <NodeB2a>

    <NodeB2a1>

    ... Mixture of nodes and elements ...

    </NodeB2a1>

    </NodeB2a>

    </NodeB2>

    </NodeB>

    ...

    <NodeZ>

    ...

    </NodeZ>

    <MyXML>

    In my output say I just want something like:

    <ReportXML>

    <NodeA1>

    ... all the elements and nodes in NodeA1 copied the same as in the original ...

    </NodeA1>

    <NodeB2a1>

    ... all the elements and nodes in NodeA1 copied the same as in the original ...

    </NodeB2a1>

    </ReportXML>

    I have played with xsl enough to get just the NodeA1 to come out after the transformation is applied but I fail at getting additional nodes to copy over. I also do not want to remove the un-needed elements because there are only a few of many I want. Say only 10% of the data from the original XML.

    Thanks for any help.

  • It's not really clear what you're looking for.

    It seems like all you're trying to do is to eliminate one node level (like NodeA, NodeB, NodeB1 a.s.o.). Is that what you want?

    If so: what are the rules for eliminating a node level?

    Please provide more details.

    Also you mentioned that you already could apply your logic to NodeA1. Would you mind sharing it? Maybe it will help us to understand what you're trying to do...



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply