pjordanna
asked on
XMLHTTP - screen scrape
Hi Experts,
I have the following xml file called "contacts.xml"
<xmp>
<?xml version="1.0"?>
<contacts>
<contact>
<field id="firstName" taborder="1">
<field_value>richard</fiel d_value>
</field>
<field id="lastName" taborder="2">
<field_value>jones</field_ value>
</field>
<field id="address1" taborder="3">
<field_value>16 some street</field_value>
</field>
<field id="address2" taborder="4">
<field_value>london</field _value>
</field>
<field id="phone" taborder="5">
<field_value>123456</field _value>
</field>
<field id="email" taborder="6">
<field_value>someemail</fi eld_value>
</field>
</contact>
</contacts>
</xmp>
And I am loading it into a page called "scrape1.asp" which uses the "microsoft.XMLHTTP" object to retieve the XML data as follows:
<%@ Language = VBScript %>
<%
Response.Buffer = True
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("Micro soft.XMLHT TP")
' Or, for version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML 2.ServerXM LHTTP")
xml.Open "GET", "http://myurl/xmlTests/contact.xml", False
xml.Send
'Display the HTML as text...
'Response.Write "<xmp>"
'Response.Write xml.responseText
'Response.Write "</xmp>"
'Or, render the HTML...
Response.Write xml.responseText
Set xml = Nothing
%>
The xml page is being rendered to the screen within scrape1.asp as expected. I have a couple of questions...
1.
How do I grab information from within the object based on the xml field name and stuff the results into a set of variables?
2.
I would also like to use this object to retrieve pure HTML pages. I would then like to grab information from the HTML pages using the regular expression object. Can you please give me an example of how to do this? An example of what I am tring to do would be:
HMTL = <td>price = £29.30</td>
VALUE IN VARIABLE = <% price %> (where price would = "29.30")
Thanks for you help...
PJORDANNA
I have the following xml file called "contacts.xml"
<xmp>
<?xml version="1.0"?>
<contacts>
<contact>
<field id="firstName" taborder="1">
<field_value>richard</fiel
</field>
<field id="lastName" taborder="2">
<field_value>jones</field_
</field>
<field id="address1" taborder="3">
<field_value>16 some street</field_value>
</field>
<field id="address2" taborder="4">
<field_value>london</field
</field>
<field id="phone" taborder="5">
<field_value>123456</field
</field>
<field id="email" taborder="6">
<field_value>someemail</fi
</field>
</contact>
</contacts>
</xmp>
And I am loading it into a page called "scrape1.asp" which uses the "microsoft.XMLHTTP" object to retieve the XML data as follows:
<%@ Language = VBScript %>
<%
Response.Buffer = True
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("Micro
' Or, for version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML
xml.Open "GET", "http://myurl/xmlTests/contact.xml", False
xml.Send
'Display the HTML as text...
'Response.Write "<xmp>"
'Response.Write xml.responseText
'Response.Write "</xmp>"
'Or, render the HTML...
Response.Write xml.responseText
Set xml = Nothing
%>
The xml page is being rendered to the screen within scrape1.asp as expected. I have a couple of questions...
1.
How do I grab information from within the object based on the xml field name and stuff the results into a set of variables?
2.
I would also like to use this object to retrieve pure HTML pages. I would then like to grab information from the HTML pages using the regular expression object. Can you please give me an example of how to do this? An example of what I am tring to do would be:
HMTL = <td>price = £29.30</td>
VALUE IN VARIABLE = <% price %> (where price would = "29.30")
Thanks for you help...
PJORDANNA
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Cheers for that...works a treat.
pjordanna