开发者

How to Modify XML using java

I have two node having same name. i want to modify one particular node value. For example

 <names> 
    <name>one</name> 
    <name>two</name>
    <name>three</name> 
    <name>four</name> 
    <n开发者_开发知识库ame>five</name> 
    </names>

In the above example i want to change last node value "five" to new value "six". is this possible in DOM..?? i am new to this concept, please guide me. Thanks for valuable replies.


Here's an example of doing exactly what you describe.

http://www.java2s.com/Code/Java/XML/JavaDOMeditLocateaNodeandChangeItsContent.htm


The A-Z of DOM using java: http://www.roseindia.net/xml/dom/


Yes. In particular, you can reference collections of child objects of 'names' as a NodeList. see Node.getChildNodes()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜