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!

XML and ASP

Status
Not open for further replies.

transparent

Programmer
Sep 15, 2001
333
GB
I have an object obj_XML which contains an xml document.

I want to create a function which grabs the nth to the mth node from the obj_xml object.

ie

grabnodes(2,5) would return nodes 2,3,4,5.

Any ideas?

Cheers
 
Yes. You would need to know which tags has the nodes you would like to grab, or provide the node with the children you would like to grab. Then you could loop through and get only the nodes in that range:
Code:
'pretend we have an xmlNode
Dim nodelist
nodelist = xmlNode.childNodes;
Dim i
For i = m to n
   If i < nodelist.count Then
      Response.Write nodelist(i).xml
   Else
      Response.Write &quot;Not enough elements&quot;
   End If
Next

That will give you the children m through n of the node xmlNode.

You can find further examples in the MSXML Dom reference at MSDN and in the XML forum.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
With enough resources, time, and coffee, anything is possible.
 
Cheers for the help. I don't think I was clear enough...I need the returned xml to be in an xml object so that I can parse it using obj_XML.transformNode(obj_xsl)

Any ideas?
 
Yes :)
If you are receiving the xml back into a string you can use the objXML.LoadXML(str) method to load that string into the dom object. It will parse out the string and create the entire dom structure for you.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top