aspose file tools
The moose likes XML and Related Technologies and the fly likes How to parse this type of XML file? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "How to parse this type of XML file?" Watch "How to parse this type of XML file?" New topic
Author

How to parse this type of XML file?

James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
I have this block in an xml file, which I'm trying to extract the data values from...


I am using JAXP/DOM and have referenced the "current_conditions" element ok, but I am struggling to reference its child nodes correctly: the node names being returned are, e.g., "temp_f" instead of "temp_f data" and (consequently?) I am unable to obtain the values such as "59".

I have done setNamespaceAware(true) on my DocumentBuilderFactory, but that has made no difference.

How can I extract the data values?!

Thanks in advance,
James
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 3791
    
    1

That's not a namespace. That's a node called temp_f, with an attribute called data. So you need to get the temp_f element, and then use getAttribute("data").
James Hodgkiss
Ranch Hand

Joined: Jan 22, 2004
Posts: 401
Thanks Matthew.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How to parse this type of XML file?
 
Similar Threads
Querying of xml using XQuery with namespace
Node Value Question
How to read XML data
Parse Excel & generate XML file
representing as XML