Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help removing some Nodes

Status
Not open for further replies.

tlhawkins

Programmer
Dec 28, 2000
797
US
hello,

I'm using ASP and DOM to handle some XML.

I have XML like this:
Code:
<response>
  <avail>
    <a>
      <code>AB</code>
    </a>
    <a>
      <code>DL</code>
    </a>
    <a>
      <code>MD</code>
    </a>
    <a>
      <code>DL</code>
    </a>
  </avail>
  <avail>
    <a>
      <code>MD</code>
    </a>
    <a>
      <code>DL</code>
    </a>
  </avail>
</response>
This is a little simplified, each <a> actaully has more children but I wanted to keep it small.

I need to remove every <a> (and all children) that has <code>DL</code> as a child.

Anybody know how I would go about this?
Thanks!

Travis Hawkins
 
in your xpath you need to find a node with DL in it
then use ancestor::a to get the a node that contains the current node.


so assuming you are using the microsoft parser, try something like

xmlDoc.selectNodes("ancestor::a
Code:
")
 
Kalisto makes a good attempt, but I think it is slightly wrong.

If you want to describe all the <a> elements that have a <code> element the value of which is 'DL', try this:
Code:
/response/avail/a[code='DL']

How this relates to ASP I will leave to others.

Tom Morrison
 
To:eek:p
>I need to remove every <a> (and all children) that has <code>DL</code> as a child.
What have you done sofar? The problem is how do you want to remove them. The natural way to doing it is also dictated by how every ingredient (xml/xsl/...) is made available to the server as an agent? TI one says: open the xml source file with notepad and select-highlight-delete, you won't be happy, will you?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top