|
-
June 7th, 2008, 10:54 AM
#7
Re: how to read XML file in Java?
 Originally Posted by dlorde
I posted two possible solutions, so it would be helpful if you said which one you're talking about, but I'm going to assume it's the SAX solution. If you look at the example (or, indeed, the SAX API docs), you'll see that the content handler startElement method callback takes an Attributes parameter. These are the attributes in the current element. You can get the value of an attribute out of the Attributes object like this:
Code:
...
startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, Attributes attributes) {
...
if ("AnElement".equals(localName) {
String attribute1Value = attributes.getValue("Attribute 1 Name");
String attribute2Value = attributes.getValue("Attribute 2 Name");
...
}
...
}
SAX serializes the XML tree structure, simply calling startElement(..) and endElement(..) for each element.
Today, most software exists, not to solve a problem, but to interface with other software...
I.O. Angell
hi, thx . will try this out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|