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!

Parsing xml coming from a javascript

Status
Not open for further replies.

Twopigs

Programmer
Apr 26, 2006
3
US
I'm a newbie to xml. Here's my situation.

I have a dealer seach i'm trying to get working. The company provided the link:


and example of parameters being passed:

Parameter:new_search value:y

Parameter:site_name value:parts+Unlimited (for Parts Unlimited Dealers)

value:Drag+Specialties (for Drag Specialties dealers)

Parameter:zip_code value:YOUR ZIPCODE

Parameter:distance value:YOUR DISTANCE



Sample:


search=y&site_name=Parts+Unlimited&zip_code=90210&distance=30

<
_search=y&amp;site_name=Parts+Unlimited&amp;zip_code=90210&
amp;distance=30>

Well, I have a form to enter the parameters and it's getting the the xml page coming back to me with all the data and I can't seem to parse it correctly.
Here's what I have so far:


any help would gladly be appreciated.
Thanks,
Scott
 
That link doesn't work. Try to be more specific with what your problem is.

Jon

"I don't regret this, but I both rue and lament it.
 
Ok, I figured I would start with something eaiser. I copied an example and tried plugging my info in it.


I took the results that I get from the main site and just made it a text xml file (testxml.xml) i'll figure out how to get the info to load directly later.

I put it in the same folder as:
here is the code for
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]

<script type="text/javascript"
for="window" event="onload">

var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("testxml.xml")

nodes=xmlDoc.documentElement.childNodes
name.innerText=    nodes.item(0).text
address1.innerText=  nodes.item(1).text
addressClose.innerText=nodes.item(2).text
phone.innerText=  nodes.item(3).text
distance.innerText=  nodes.item(4).text
url.innerText=  nodes.item(5).text
</script>

<head>
	<title>PLFormNew</title>
	<meta name="generator" content="BBEdit 8.2" />
</head>
<body>
Below is the test xml file: (testxml.xml) located in the same folder as test1.html
	<p align="justify">
<b>Dealer Name: </b>
<span id="name"> </span>
<br />
<b>Address: </b>
<span id="address1"></span>
<hr>
<b><span id="addressClose"></span></b>
<hr>
<b><span id="phone"></span></b>
<hr>
<b>Distance: </b>
<span id="distance"></span>
<br/>
<b>URL: </b>
<span id="url"></span>
</p>

</body>
</html>

I figured this may be eaiser to start with. Thanks in advance for any help.
Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top