Click to See Complete Forum and Search --> : How to avoid hard coding second XML document


Karla
03-16-2000, 01:03 PM
The concept is:

I am producing a second XML from sub parts of a first XML. I want to grab
all of the data and sub-tags from <author>, both data and tagging, from the
first XML to be placed in the second XML without hard-coding all of the child-elements.
How can I do this given the following example?


First XML ( Original info )

<doc>
<author>
<firstname>
Joe
<\firstname>
<lastname>
Smith
<\lastname>
<\author>

<publisher>
blah blah blah
<\publisher>
<\doc>


Second XML ( Desired Result )
<author_list>
<author>
<firstname>
Joe
<\firstname>
<lastname>
Smith
<\lastname>
<\author>

<\authors_list>

Greg Longtin
03-16-2000, 02:38 PM
Karla,

You can use either the DOM or XSL for this. What application were you
trying to do this in?

Some hints, using the DOM, use cloneNode and appendChild, after
..selectNodes(doc/author). In XSL, the copy-of element would work...


HTH,

Greg Longtin

"Karla " <T3stillwell@hotmail.com> wrote in message
news:38d113d9$1@news.devx.com...
>
> The concept is:
>
> I am producing a second XML from sub parts of a first XML. I want to grab
> all of the data and sub-tags from <author>, both data and tagging, from
the
> first XML to be placed in the second XML without hard-coding all of the
child-elements.
> How can I do this given the following example?
>
>
> First XML ( Original info )
>
> <doc>
> <author>
> <firstname>
> Joe
> <\firstname>
> <lastname>
> Smith
> <\lastname>
> <\author>
>
> <publisher>
> blah blah blah
> <\publisher>
> <\doc>
>
>
> Second XML ( Desired Result )
> <author_list>
> <author>
> <firstname>
> Joe
> <\firstname>
> <lastname>
> Smith
> <\lastname>
> <\author>
>
> <\authors_list>
>
>
>