Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

obtain property xml

 
Jhonnathan Emilio Cardona Saineda
Ranch Hand
Posts: 38
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have this xml
<test>
<ws>Hello world</ws>
</test>

for obtain the property ws, i use this code.
Document cnf = new Document(new File("file.xml"));
String property = cnf.getElement(new XPath("/test/ws")).getTextString();

How do I get the property if there are 2 tags with the same name? for example:
<test>
<ws>Hello world</ws>
<ws>other Hello world</ws>
</test>

thanks
 
g tsuji
Ranch Hand
Posts: 650
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The framework/library in use is curiously left unmentioned here... Here is a plausible code that might just work.

If it does not work to the letter, take it as pseudo-code as the library in use in at everybody's guessing.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic