• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Exctract cirtain categories of products from XML products file

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am absolutely novice to the XML and maybe somebody can give me a hint with the problem I faced.

I have got the XML file with productrs of internet shop like below

<category id="3">Tree for web</category>
<category id="5663" parentId="8108"> Love books</category>
<category id="5664" parentId="1090946">Benconni Julitte</category>
<offer id="1041668">
<name>Name of product</name>
<description> desc</description>


So If you can see there is a tree structure of categories for goods. Is it possible to extract to another XML file cirtain category with subcatigories and all products which are in that categories.

Thank you in advance
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got a number of choices. You could transform the XML you have using XSLT to produce a new document with the data you need.

Or you could use XPath to select the nodes you are interested in. If you're not comfortable with XPath, XQuery does a simmilar job.

Or you could parse the document and programatically handle the data; given you have to jump about in the document DOM parsing would be the easier choice. Have a look at the JEE tutorial and the section covering XML parsing.
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!