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

SelectSingleNode & return node index from DOM Document

Status
Not open for further replies.

magiccity

Programmer
Aug 22, 2003
6
US
Can anyone tell me how to get the index of the node returned by the SelectSingleNode
method?
 
If you are looking for a DOM standard function of the Node or Element object there is not one. If your asking something else clarify your question. There is almost zero information in your post.

See this FAQ: faq333-3811 "Five steps to asking a question"



-pete
 
My apologies...I was trying to keep it simple. I believe you have already answered my question but I will elaborate in case anyone has any further ideas.

I have code that loads up an interface file from the client and converts it to XML. I have developed a web-based front end to act as a transaction viewer\editor\search engine. One interface file could contain thousands of transactions so it is necessary for the user to be able to search and the app to retrieve the specified transaction. It is also imperative that the placement of the transaction within the interface file be returned because order of processing is critical and I need to know where to begin when the user searches for the next matching transaction.

I am using SelectSingleNode to find the specified transaction but I also need to know the value of the returned node's index in respect to all other transactions(ie 31 of 5261). I was originally spinning through a "For Loop" to search but this proved inefficient on a large number of transactions.

Thanks!
 
Seems like a reasonable requirement if I follow correctly.

>> I was originally spinning through a "For Loop" to search

Yes that is the obvious approach I used to create a generic method of an Element object for reuse purposes. However you have two attributes of your project that indicate a different solution. (1) you have large thousands numbers of elements to search. (2) You are creating the XML tree!

Since your creating the XML from a proprietary data format I would consider adding unique id attributes and values to the elements you need to search at creation time. Then use that attribute to locate specific elements using XPath queries.


-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top