• 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 ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

Exctract cirtain categories of products from XML products file

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

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

<shop>
<categories>
<category id="3">Tree for web</category>
<category id="5663" parentId="8108"> Love books</category>
<category id="5664" parentId="1090946">Benconni Julitte</category>
.....
</categories>
<offers>
<offer id="1041668">
<url>http://www.DOMAIN.com/context/detail/id/1041668/?from=partner</url>;
<price>325</price>
<currencyId>USD</currencyId>
<categoryId>1095606</categoryId>
<categoryId>1102171</categoryId>
<picture>http://www.domain.com/multimedia/audio_cd_covers/zvezda7213.jpg</picture>;
<orderingTime>
<ordering>Stock</ordering>
</orderingTime>
<name>Name of product</name>
<vendorCode>7213</vendorCode>
<description> desc</description>
</offer>

....



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
 
Bartender
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)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!