Changing an XML tag value easy

S

shoe

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top