• 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

Eliminating some xml nodes.....

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's say for example, i want to store the following xml file as a CLOB object in the database, but i don't want to store the following lines in that CLOB object. Is there a way to eliminate <purchaseOrders> node. I am using JAXB. Can anyone help me on this? The reason i don't want to store this <purchaseOrders> node is, i want to create another xml document, add to it multiple purchaseOrder, with only one <purchaseOrders> node.
<?xml version="1.0" ?>
- <purchaseOrders>
</purchaseOrders>
---------------- File starts here ---------
<?xml version="1.0" ?>
- <purchaseOrders>
- <purchaseOrder orderDate="1999-10-20">
- <shipTo country="US">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Cambridge</city>
<state>MA</state>
<zip>12345</zip>
</shipTo>
- <billTo country="US">
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Cambridge</city>
<state>MA</state>
<zip>12345</zip>
</billTo>
- <items>
- <item partNum="242-NO">
<productName>Nosferatu - Special Edition (1929)</productName>
<quantity>5</quantity>
<USPrice>19.99</USPrice>
</item>
- <item partNum="242-MU">
<productName>The Mummy (1959)</productName>
<quantity>3</quantity>
<USPrice>19.98</USPrice>
</item>
- <item partNum="242-GZ">
<productName>Godzilla and Mothra: Battle for Earth/Godzilla vs. King Ghidora</productName>
<quantity>3</quantity>
<USPrice>27.95</USPrice>
</item>
</items>
</purchaseOrder>
</purchaseOrders>

Thanks.
Appreciate your help !
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to eliminate <purchaseOrders> node
So you want to remove only this element or this element
and all of its child elements also....could you clarify please...
Thanks.
- m
 
Mandy S Smith
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to remove only <purchaseOrders></purchaseOrders> node and not its child ie <purchaseOrder></purchaseOrder>
Is there a way to do this, just to remove an element from the document.
I know, we can get rid of the xml declaration by setting the followin property.
m.setProperty("com.sun.xml.bind.xmlDeclaration",Boolean.FALSE);
Appreciate your response on this.
Thanks !
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you use XSLT instead to create a new XML document without the <purchaseOrders></purchaseOrders> element, just make sure the new document is well formed.
then you can do whatever you want with it.
Wouldn't that be easier?
 
The City calls upon her steadfast protectors. Now for a 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