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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nodeFromId method without IDREF's ??

Status
Not open for further replies.

MrPeds

Programmer
Jan 7, 2003
219
GB
Hi,

I would like to use a DOM method that returns a single node from an xml document given a specific ID attribute.

I have tried using the nodeFromId method, but am not able to get it to work. From what I can make out, this method is only for ID/IDREF relationships.(?)

I would like some way of achieving the above but I think I need another method or approach.

Could anybody sugggest code or references on how to do this please. I know the syntax of the above method, but am not able to get it to work :/

Thanks

Peds
 
as you do not mention the DOM you are using, its hard to help.. however I can say you need to use an xpath expression like this:

//mynode[id=$var]

If the id is unique (which you do not mention either) then only one node will be returned.

In msxml, selectSingleNode takes xpath expressions to return a single node object. its a bit different in java, and im not going into it here specially as I'm not sure this is what you need.


hope that helps a bit

matt


 
That is exactly what i needed - the MS XML SDK 3.0 was ambiguous as to the nodeFromId method.

The selectSingleNode(XpathStr) works fine.

I was using MSXML DOM implementation 3.0 with VBScript in ASP pages.

Hope this helps others

MrPeds
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top