wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes How to update the xml tag attributes for the given tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to update the xml tag attributes for the given tag" Watch "How to update the xml tag attributes for the given tag" New topic
Author

How to update the xml tag attributes for the given tag

kiranb reddy
Greenhorn

Joined: Sep 28, 2008
Posts: 20
Hi,
I have a requirement to update the xml file which contains around 20 tags with different attribute values for each tag.

My requirement is i need to update the attribute values of the tag.

Here, i am giving my xml file.
<class max no="1000"
seats ="2000">

<student name ="a1" age="10"> x1</student>
<student name ="a2" age="11"> x2</student>
<student name ="a3" age="12"> x3</student>
<student name ="a4" age="13"> x4</student>
<student name ="a5" age="14"> x6</student>
<student name ="a6" age="15"> x7</student>
</class>

now i need to modify the attribute values of class tag, and student tag ( for the given student for eg. x6)

How can i do this using java ?

Could any one give me the code for doing the above task.

Thanks,
Nikith C
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12785
    
    5

1. Learn how to parse an XML document into a DOM (Document Object Model) in memory.
2. Learn how to locate elements within the DOM by name.
3. Learn how to access and alter the attributes in an element.
4. Learn how to write the modified DOM to a file.

Harold's book "Processing XML with Java" is a good place to start.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to update the xml tag attributes for the given tag