• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Grabbing the middle of an XML document

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm using java 1.4.2 with JDom and I was wondering is there a way to strip out the middle of an xml document using XPath?

For example, if my xml file was as so:

<root>
<title>My Title</title>

<body>
<top>TOP</top>

<middle>MIDDLE</middle>

<bottom>BOTTOM</bottom>
</body>
</root>

I would like to be able to use "/root/body" to extract the body segment in it's entirety as a string. I'm basically reading an xml document and saving a copy with some headings and such removed.

I was looking at selectNodes method, but passing an XPath expression into this returns the node ('Element' object) and the only thing I see that I can do from there is to iterate recursively through all the children. If this is the case however, it would be easier for me to read the file in and manually scan through it until I find the required node and copy until the closing tag of that node.

Any help is much appreciated,
Thanks
 
Jon Bon
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again,

I've gotten a response that sorts out my question over here

http://forum.java.sun.com/thread.jspa?threadID=5126101&tstart=0

Thanks for reading.
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic