Get attribute value from XML node help

QuietRiot

Well-known Member
Joined
May 18, 2007
Messages
1,079
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. MacOS
I'm trying to get the href value (the url for the next page) of the next position in the below XML, but I can't figure out how to get that attribute.

edit: not sure why it wont show the xml tags changed it a bit:
Code:
{api:pagination results-count="200" items-per-page="25"}
		{api:page position="this" href="https://test.com/api/test/12345"/}
		{api:page position="next" href="https://test.com/api/test?detail=full"/}
{/api:pagination}


Code:
    objHTTP.Open "GET", URL, False
    objHTTP.setRequestHeader "Authorization", Auth_Key
    objHTTP.send
    'strResult = objHTTP.responseText
    
    objXML.async = False
    objXML.LoadXML (objHTTP.responseText)
    
    'Dim xItemList As IXMLDOMNodeList
    'Set xItemList = objXML.DocumentElement.SelectNodes("//api:page")
    
     Dim xItem As IXMLDOMNode
     
     xItem = objXML.SelectSingleNode("//api:pagination/page").Attributes.getNamedItem("href") 
     'xItem = objXML.SelectSingleNode("//api:pagination/api:page[@position=""next""]"



thanks,
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Here is the answer:

Set xItem = objXML.SelectSingleNode("//api:page[@position=""next""]/@href")
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top