This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes obtain property xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "obtain property xml" Watch "obtain property xml" New topic

obtain property xml

Jhonnathan Emilio Cardona Saineda
Ranch Hand

Joined: Jan 24, 2012
Posts: 32

Hi, I have this xml
<ws>Hello world</ws>

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:
<ws>Hello world</ws>
<ws>other Hello world</ws>

g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 499
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.
It is sorta covered in the JavaRanch Style Guide.
subject: obtain property xml
Similar Threads
New to Webservices. want to know required jars and tools and know how to implement Hello World WS.
Help regarding web service security
Websphere JSP deployment problem