• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Code sample request

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,
Given this small xml:
<message>
<from> aaa </from>
<to> bbb </to>
<cc> ccc </cc>
<text> Hello </text>
</message>
Could somebody please send me a small piece of Java code preferable using DOM showing how to extract values "aaa"
"bbb" "ccc" and "Hello"?
Thanks in advance
Ambrose
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ambrose,
Unfortunately I can not take the time to do the actual code for you, but I can tell you how to proceed in order to accomplish what you are asking...
First of all you need to use a DOMParser object to parse your xml file into a DOM Document (). Once you have this you could search the elements by using the getElementsByTagName method and then get the child node of the element (which would be a text node type). After this you could use the getNodeValue method to return you corresponding text values....
Hope this helps!
Cheers!
Johannes
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic