Changing an XML tag value easy

From: shoe (hassehb_at_yahoo.com)
Date: 06/29/04


Date: 29 Jun 2004 03:44:16 -0700

Terrible simple question i think but I'm to tired mocking around now
for 2 days with this problem !

I want to change one "name" tag value ONLY in this XML (below).
Notice that there are many "name" tags.

I can search trough this xml using a Dom parser but that will give me
a list of all name tags - using this syntax:
doc.getElementsByTagName("name");

how do I directly access and change the deepest "name" tag:
projectDescription/buildSpec/buildCommand/name ??????

I have trķed this: (does not work)!
doc.getElementsByTagName("projectDescription/buildSpec/buildCommand/name");
to get a lock on that tag and then simply change the value.

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
        <name>testc++</name>
        <comment><comment>
        <projects></projects>
        <buildSpec>
                <buildCommand>
                        <name>makeBuilder</name>
                </buildCommand>
        </buildSpec>
        <natures>
                <nature>cnature</nature>
                <nature>makeNature</nature>
                <nature>ccnature</nature>
        </natures>
</projectDescription>



Relevant Pages

  • Re: How can I ensure that I always have a list?
    ... tdom is an XML parsing extension for Tcl. ... # Match one tag. ... # quotes, ... # key/value pair) for further processing the next time we go ...
    (comp.lang.tcl)
  • Re: How can I ensure that I always have a list?
    ... tdom is an XML parsing extension for Tcl. ... # Match one tag. ... # quotes, ... # key/value pair) for further processing the next time we go ...
    (comp.lang.tcl)
  • Re: ruby html (or xhtml) forms class...
    ... xx is a library designed to extend ruby objects with html, xhtml, and xml ... xml or xhtml as clean looking and natural as ruby it self. ... attributes may be passed to any tag method as either symbol or string. ...
    (comp.lang.ruby)
  • Re: Cant read CString after serialization
    ... it was not the time to build steam engines. ... the DTD syntax would be expressed in XML!) ... parse the file and show it (for example, a columnar display of tag id, tag ... We built huge systems using these techniques. ...
    (microsoft.public.vc.mfc)
  • Re: Errors on processing 2GB XML file by using XML:Simple
    ... > which might due to the XML file itself. ... until you see a completed tag (opening tag followed by arbitrary amount of ... If the tag we just found matches the twig ... Delete the links from the dangling hash/DB ...
    (perl.beginners)