This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieve data from childs in XML

 
Isaac Ferguson
Ranch Hand
Posts: 831
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i

In order to access to this data in my .xml

<company>
<dimension>
<CityName>Boston</CityName>
<browser>Explorer</browser>
</dimension>
</company>


I use the method:



company = companyData.item(0);
if (company.getNodeType() == Node.ELEMENT_NODE) {

Element elemento = (Element) company;
String com = getTagValue("name", elemento);
if (com.equals(companyName)) {

this.setDimension(getTagValue("dimension", elemento));


}



// Return nodo with data
return company;

}

public String getTagValue(String tag, Element elemento) {

NodeList lista = elemento.getElementsByTagName(tag).item(0)
.getChildNodes();

Node valor = (Node) lista.item(0);

return valor.getNodeValue();

}


I need retrieve values store in the tags "CityName" and "browser". What way could I get them?

Many Thanks,

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic