Jessee
asked on
VB.Net Help with reading the attached XML into a listbox
Hey there,
I am needing to read the XML from the following URL: http://api.trademe.co.nz/v1/Member/3245655/Listings/All.xml
I want to add each title into a listbox.
Attached is my current code.
I am needing to read the XML from the following URL: http://api.trademe.co.nz/v1/Member/3245655/Listings/All.xml
I want to add each title into a listbox.
Attached is my current code.
Public Sub GetAllListings(ByVal MembershipNumber As String)
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
m_xmld = New XmlDocument()
'Load the Xml file
m_xmld.Load("http://api.trademe.co.nz/v1/Member/3245655/Listings/All.xml")
'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("//Listing")
'Loop through the nodes
For Each m_node In m_nodelist
TMMain.lstListings.Items.Add(m_node.ChildNodes(1).InnerText)
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Hi,
You can use any of following codes
You can use any of following codes
Public Sub GetAllListings(ByVal MembershipNumber As String)
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
m_xmld = New XmlDocument()
'Load the Xml file
m_xmld.Load("http://api.trademe.co.nz/v1/Member/3245655/Listings/All.xml")
' Create an XmlNamespaceManager for to resolve the default namespace.
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(m_xmld.NameTable)
nsmgr.AddNamespace("api", "http://api.trademe.co.nz/v1")
'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("/api:Listings/api:List/api:Listing", nsmgr)
'Loop through the nodes
For Each m_node In m_nodelist
TMMain.lstListings.Items.Add(m_node.ChildNodes(1).InnerText)
Next
End Sub
Public Sub GetAllListings(ByVal MembershipNumber As String)
Dim m_xmld As XmlDocument
Dim m_nodelist As XmlNodeList
Dim m_node As XmlNode
m_xmld = New XmlDocument()
'Load the Xml file
m_xmld.Load("http://api.trademe.co.nz/v1/Member/3245655/Listings/All.xml")
' Create an XmlNamespaceManager for to resolve the default namespace.
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(m_xmld.NameTable)
nsmgr.AddNamespace("api", "http://api.trademe.co.nz/v1")
'Get the list of name nodes
m_nodelist = m_xmld.SelectNodes("/api:Listings/api:List/api:Listing/api:Title", nsmgr)
'Loop through the nodes
For Each m_node In m_nodelist
TMMain.lstListings.Items.Add(m_nodelist(0).InnerText)
Next
End Sub
ASKER