Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within XML
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
XML and Related Technologies
Reading XML Values
Raistlen Majere
Greenhorn
Posts: 15
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I want to retrieve all values from an xml no matter what the tag. Currently I have the code working for a normal xml:
ArrayList xmlHold = new ArrayList(); //get the root element Element docEle = document.getDocumentElement(); //get a nodelist elements NodeList nl = docEle.getElementsByTagName("*"); if(nl != null && nl.getLength() > 0) { for(int i = 0 ; i < nl.getLength();i++) { //get the element Element el = (Element)nl.item(i); String version = el.getTextContent(); if (version != null | version != "") { xmlHold.add(version.trim()); } } }
The problem I am having is when I need to read the value of a tag in the following format:
<import resource="somecustomconfig.xml" />
I need to extract the "somecustomconfig.xml" and I can not get it to work. Is there a quick fix to this using my current code structure?
Campbell Ritchie
Marshal
Posts: 79153
377
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Too difficult a question for "beginning Java". Moving.
David Newton
Author
Posts: 12617
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
element.getAttribtue(
String
name)
?
Raistlen Majere
Greenhorn
Posts: 15
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
element.getAttribtue(String name)
The only problem is I will not know the contents of the xml, so I can not pass it name parameter.
David Newton
Author
Posts: 12617
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You're reading random XML?
public NamedNodeMap getAttributes()
Reading the API will help you.
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
need help in edit the xml using dom parser
xml tags writing
Dom parser for XML file
[JAVA] XML reader
JAXB namespace use in XML files
More...