Hi Marc

I guess it depends on what you want to get. For example you could get the
<intro> element and iterate through its content and do different things
depending on if its a Text node or an Element node?

Element intro = ...;
for ( Iterator iter = intro.nodeIterator(); iter.hasNext(); ) {
    Node node = (Node) iter.next();
    if ( node instanceof Element ) {
        ...
    }
    String xml = node.asXML();
    // whatever...
}

So I guess it depends on what you want to do. Are you trying to output the
XML of whats inside the <intro> XML without the <intro> tag? If so this
should do the trick fine...

Writer out = new FileWriter( "foo.xml" );
for ( Iterator iter = intro.nodeIterator(); iter.hasNext(); ) {
    Node node = (Node) iter.next();
    node.write( out );
}

James
----- Original Message -----
From: "Marc Elliott" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 01, 2001 2:06 PM
Subject: [dom4j-user] database to document OK, but document to database...


Hi folks,

I've done pretty well getting dom4j to take content from my database and
construct a document object and then an XML file, but I'm having a bit
of a trouble getting the data I need out of a document and putting into
the database.

The problem appears to be rooted in the fact that my XML documents are
somewhat unstructured with mixed content at different levels.

For example:

<intro>
<p><b>Content, content, content</b></p>
<p>More, content, contentcontent, contentcontent,
contentcontent, contentcontent, contentcontent, contentcontent,
contentcontent, contentcontent, contentcontent, contentcontent,
contentcontent, contentcontent, contentcontent, contentcontent,
contentcontent, <some other tag>contentcontent</some other tag>,
contentcontent, contentcontent, contentcontent, contentcontent,
content</p>
</intro>

If I grab this content using the asXML method on the intro node, the
<intro> tags come with it, and I don't want them to.  But if I use the
getText or the getValueOf method, it won't return anything in the <p>
tags.  Is there a better way to go about this?

Thanks,

Marc

..................................................

Marc Elliott
Director of Information Architecture / HNW Inc.
Digital Solutions for High-Net-Worth Marketers
ph: 617-243-9199 x224
fx: 815-327-4167


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to