XML problem that’s got me stumped, but is probably very simple…
The XML is like:
<header>
<createdOn>16 Sep 2009</createdOn>
<createdBy>Jez</createdBy>
</header>
<agents>
<agent>
<agentDetails>
<agentName>text</agentName>
<agentTelephone>text</agentTelephone>
</agentDetails>
<properties>
<property>
<propertyid>number</propertyid>
<address>
<number>1</number>
<street>High St</street>
<postcode></postcode>
<country>UK</country>
</address>
<price>
<category>text</category>
<price>number</price>
<reference>text</reference>
</price>
<description>
<propertyType>House</propertyType>
<bedrooms>2</bedrooms>
<bathrooms>1</bathrooms>
<sleeps>
<briefDescription>text</briefDescription>
<addDescription>long-text</addDescription>
<floorSize>
<size>80</size>
<type>sq. mt</type>
</floorSize>
<bullets>
<bullet>No Of Bedrooms : 2</bullet>
<bullet>Condition : Habitable</bullet>
<bullet>Land Size (M2): 2,000</bullet>
</bullets>
</description>
<images>
<image>
<thumbnail>URL</thumbnail>
<image>URL</image>
<alttext></alttext>
</image>
<image>
<thumbnail>URL</thumbnail>
<image>URL</image>
<alttext></alttext>
</image>
</images>
<links>
<link>
<type>text</type>
<url>url</url>
</link>
<link>
<type>text</type>
<url>url</url>
</link>
</links>
</property>
</properties>
</agent>
</agents>
And the code I would like to use is:
Set NodeList = objXML.documentElement.selectNodes("agents/agent/properties/property")
For Each Node In NodeList
'I want to be able to extract distinct fields here...
response.write Node.selectSingleNode("address/street") & "<br/>"
response.write Node.selectSingleNode("description/briefDescription") & "<br/>"
Next
But, I don’t know how.
ALso, this could be a problem with, for example, the <images> and <links> tags.
Suggestions please?
First, the XML example you’ve posted is invalid. It lacks a root element (or has multiple root elements, depending on your point of view). Also, the
<sleeps>element is never closed. I think these might be typos in your example?I’m not sure what you mean by “I want to be able to extract distinct fields here.” Can you give an example of the output that you are after?
Without more information, I can suggest trying some variation of this:
Does this help?