"Nesting" XML documents using DOM

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Lee

    #1

    "Nesting" XML documents using DOM

    Hi everyone,
    I'm trying to nest one XML document inside another, but the only
    method I can think of (not being familiar with Java and DOM!) would
    involve nested while loops.

    Basically, I have something like this:

    <Book>
    <Title>blob</Title>
    <Author>blobb y</Author>
    .... etc ...
    </Book>

    What I'm trying to do is import another XML doc. where the Author tag
    is located, so it becomes
    <Author>
    <First Author>a</First Author>
    <Second Author>b</Second Author>
    </Author>

    There must be a very simple way to do it in DOM but my head hurts!

    (by the way, how do I export the resultant Document into String
    format? I've looked at obvious solutions such as any "getText()"
    functions, but help
    pages refer to traversing each node in turn and parsing them into
    text)

    TIA

    Paul
Working...