Home > ASP Development > ASP and XML

ASP and XML



Hi guys, ive created an xml file and now need to create an asp which links to the xml file.



i can create xml and asp files seperatly but am strugglin linking them together.



any knowledge wud be great!

    
Guest


what you mean link them?

maybe what you need is xsl:

http://www.w3schools.com/xsl/

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by Shadow Wizard
what you mean link them?

maybe what you need is xsl:

http://www.w3schools.com/xsl/




i understand xsl. but that will only display data. i think.



i could do with manipulating the data from the xml file via asp.



any ideas?

Was this answer helpful ? Yes No   
Guest


here is good article then:

http://www.4guysfromrolla.com/webtech/101200-1.shtml

Was this answer helpful ? Yes No   
Guest


here is one i am doing now, it works

you have to alter bits but read it, it is very simple




Code:



<%

Dim xmlDoc, i, prodId, Stock
Dim root
Set xmlDoc = Server.CreateObject("MSXML2.DOMDocument")
xmlDoc.async = False
xmlDoc.setProperty "ServerHTTPRequest", true
xmlDoc.Load ("http://yourdomain.com/xml.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
Response.Write("You have error " & myErr.reason)
Else
Set root = xmlDoc.documentElement


For i = 0 To (root.childNodes.length - 1)
'you will have to alter this for your fields
prodId= cStr(root.childNodes.Item(i).childNodes.Item(0).Te xt)
Stock = cStr(root.childNodes.Item(i).childNodes.Item(1).Te xt)



ToUpdate = HaveGot(prodId)

If ToUpdate <> 0 Then 'update the record
mysql2 = "UPDATE products SET stock="&Stock&" WHERE sku='"&prodId&"'"

call updateDatabase(mysql2,rsTemp2,"updateStock")

call CloseDb()

response.Write "updated record "&prodId&" With Stock Amount:"&Stock& "<BR>"

else
End If
'open database, check for prodid, if have then update quantity with stock
Next

call closeDb()

StrTotal = i

response.Write "there is a total of : " &i& " Records"
End If

Function HaveGot(sku)
mysql = "SELECT sku FROM products WHERE sku='"&sku&"'"
call getFromDatabase(mysql,rstemp3,"checksku")

If not rstemp3.eof Then
HaveGot = -1
Else
HaveGot = 0
End IF

End Function






some of this code was possible because of help i got here, so now i am giving back. i hope it helps

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved