简体   繁体   中英

How can i add element and value in XML?

I have this XML file:
(Actually, right now it is a StringBuffer, i don't want to save it to a file, i want to use it from the memory directly)

StringBuffer book =  
<book>
 <title>test</title>
 <bookinfo>
  <page>100</page>
 </bookinfo>
</book>

In here, i want to add a element and a value like this:

<book>
 <title>test</title>
 <bookinfo>
  <page>100</page>
  <price>100</price>
 </bookinfo>
</book>

what is the fast and easiest way to add an element and value in XML?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM