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

Discussion in 'XML' started by HANM, Jan 29, 2008.

  1. HANM

    HANM Guest

    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
     
    HANM, Jan 29, 2008
    #1
    1. Advertising

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

    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/
     
    Martin Honnen, Jan 29, 2008
    #2
    1. Advertising

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

    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
     
    Joseph Kesselman, Jan 29, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mansour via DotNetMonster.com

    when i try to insert or update text in arabic it appears "????"

    mansour via DotNetMonster.com, Sep 11, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    802
    Juan T. Llibre
    Sep 11, 2005
  2. Alexander Widera

    insert into/update table in db with long text

    Alexander Widera, Feb 2, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    3,208
    S. Justin Gengo [MCP]
    Feb 4, 2006
  3. jkflens
    Replies:
    2
    Views:
    1,535
    jkflens
    May 30, 2006
  4. luckyads
    Replies:
    0
    Views:
    586
    luckyads
    Jan 21, 2009
  5. luckyads
    Replies:
    0
    Views:
    445
    luckyads
    Jan 22, 2009
Loading...

Share This Page