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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP to retreive xml data

Status
Not open for further replies.

Riksta

Programmer
Dec 7, 2003
16
GB
Hi, beginer here!

I have stored some Information in xml such as:

<person>
<fname> John </name>
<sname> smith </sname>
<loginid> J.smith@.... <loginid>

Now, I have created a login page. So when John puts his login id into the field, then it will go into the xml and check if it is J.smith@.... if it validates then it will display his information back to me???

So what Im looking for is some code in asp to go looking through the xml data. Instad of using SQL or something to store my info I have used XML as a way of storing and retrieving.
 
Hi Riksta,

To search in a XML from ASP you need to use a XML parser. I do use XML in my ASP pages the code I use and works properly is the following one:

Dim xmldom, isload, xmlnode, xmlnodelist1
Set xmldom = Server.CreateObject(&quot;Microsoft.XMLDOM&quot;)
xmldom.async=false
isload = xmldom.loadXML ( YOUR_XML_FORMAT )
if isload then
Set xmlnodelist1 = xmldom.documentElement.childNodes
for each e in xmlnodelist1
if e.nodeName = &quot;loginid&quot; then
if e.Text = &quot;login id input from user&quot;
'Is the one that logged in
end if
enf if
Next
set xmlnodelist1 = Nothing
set xmldom = Nothing
Else
set xmldom = Nothing
end if

You should modify the for next sentence but this is the way I use to parse XML inside ASP pages

Hope it helps

 
Hi,

thanks for the reply. I will go away and try this but know doubt some how I will have problems so I will be back for more answers.

Thanks again.
 
Hi,

I have been trying this code but I guess im just a dumb programmer. I was trying and trying and then got tired of it so I just left it. I guess I should not give up so I have picked it back up again.

Do I need the FOR loop??
isload = xmldom.loadXML ( YOUR_XML_FORMAT )= Should my name of my xml file be included within here??

Sorry about this.

Thanks

Rik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top