DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to avoid hard coding second XML document

  1. #1
    Karla Guest

    How to avoid hard coding second XML document


    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>




  2. #2
    Greg Longtin Guest

    Re: How to avoid hard coding second XML document

    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>
    >
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center