Results 1 to 3 of 3
Thread: XML Help
- 07-11-2007, 06:32 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 5
- Rep Power
- 0
XML Help
Hi everyone,
I am trying to manipulate an xml file by reading the document, finding a specific attribute and changing its value. I have written the DOM and but I can't access the attribute or its value. Could someone help me with this. Im using the code below as practice:
<?xml version='1.0'?>
<catalog>
<book catagory="Technical">
<title>Java Programming</title>
<author>Lewis and Lofus</author>
</book>
<book catagory="Entertainment">
<title>Cosmo</title>
<author>Paul Lous</author>
</book>
<entry id="a1253">
</entry>
</catalog>
say for instance i was trying to change the value in the entry id attribute.
- 07-11-2007, 07:10 PM #2
Senior Member
- Join Date
- Mar 2007
- Posts
- 134
- Rep Power
- 0
Hey you can use Xpath inside the document to fetch the node like this
Then get the attribute of it and you can either remove the node and add the fresh node with new attribute id.Java Code:document.selectSingleNode("/catelog/entity");
I would recommend to use the XSLT to manage this if the XML transformations is very frequent
thanks
goldhouse
- 07-11-2007, 10:16 PM #3
Member
- Join Date
- Jul 2007
- Posts
- 5
- Rep Power
- 0


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks