*
The moose likes XML and Related Technologies and the fly likes How to get a part of xml document in String format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to get a part of xml document in String format" Watch "How to get a part of xml document in String format" New topic
Author

How to get a part of xml document in String format

Aryan Khan
Ranch Hand

Joined: Sep 12, 2004
Posts: 290

Hi all,
How to get a portion of a xml document in String format.

>
So I want to read only from element B (So it wil B C & D) and get the representation of this in String with the xml tag names as well.
I tried XPath which provides the element values only and not the tag names.

Also want to avoid recursively iterating and generating the xml document.

Looking for some thing neat like (XPath not necessary):

XPath.evaluate("B","XMLDoc.xml") // and the result be as above.
Thanks

P.S. the xml documents do not have any attributes.


OCP/MCP/SCJP/SCWCD/IBM XML/SCMAD/SCEA-1
Aryan Khan
Ranch Hand

Joined: Sep 12, 2004
Posts: 290

Any one pls?
Aryan Khan
Ranch Hand

Joined: Sep 12, 2004
Posts: 290

Ok I found a pretty good solution.

I put a simple XSL stylesheet like:


This ll actually copy the xml document.

Then I used the XSL transformation java api to call this from application and pass the DOM...

Aryan
 
Don't get me started about those stupid light bulbs.
 
subject: How to get a part of xml document in String format
 
Similar Threads
attributes
Mapping Elements to new Elements
Xpath Expression correction
XPath
XPath Expression doubt