Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > how to Update/insert an xml element's text----> (<element>text</element>)

Reply
Thread Tools

how to Update/insert an xml element's text----> (<element>text</element>)

 
 
HANM
Guest
Posts: n/a
 
      01-29-2008
hello friends,
how can we update or insert into an xml Element.
For example :
-------------------

<?xml version="1.0">
<request>
<main>
<name>ISO8856</name>
</main>
</request>

here when we run a java class file it should replace "ISO8856"with
"ISO9001". Any Assistance or example.

thanQ in adv.
Ajay
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      01-29-2008
HANM wrote:

> <?xml version="1.0">
> <request>
> <main>
> <name>ISO8856</name>
> </main>
> </request>
>
> here when we run a java class file it should replace "ISO8856"with
> "ISO9001". Any Assistance or example.


If you use the W3C DOM Level 3 Core as implemented in Java 1.5 and later
then you can select the 'name' element and set its textContent e.g.
Element name = (Element)xmlDocument.getElementsByTagName("name"). item(0);
name.setTextContent("ISO09001");
If you use DOM Level 2 Core (as implemente in Java 1.4) then you need to
access the firstChild and set its nodeValue
Element name = (Element)xmlDocument.getElementsByTagName("name"). item(0);
name.getFirstChild().setNodeValue("ISO09001");


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Joseph Kesselman
Guest
Posts: n/a
 
      01-29-2008
Many good tutorials/articles exist on the web (and some bad ones, alas).
I usually point people to http://www.ibm.com/xml

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM
What XML technologies to learn first for "XML Processing" and "XML Mapping"? Bomb Diggy Java 0 07-28-2004 07:26 AM
Help on including one XML document within another XML document using XML Schemas Tony Prichard XML 0 12-12-2003 03:18 PM



Advertisments