Help...help I am new to xml.I am getting some xml files from a data-feed. Some of the xml documents contains a link under the <item-content>. some others contain <html> tag (see sample below). I need to be able to redirect the page to the webaddress provided inside of the <item-content> tag OR just display content if <item_content> contains and <html> tag. In user can click on any link on the main asp page. Once the user clicks on a link it calls getPage.asp. getPage.asp containts code to parse the xml file and redirect page.
This is what I got..still having problems displaying te content...Thanks..
Any other suggestion on how to do this is welcome
Thanks,
-------- main.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<a href="getPage.asp?item=sample1.xml">sample1</a>
<a href="getPage.asp?item=sample2.xml">sample2</a>
</body>
</html>
-------- getPage.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim vItem
vItem = request.QueryString("item")
Dim objXMLDoc, xmlFile
xmlFile = vItem
Set objXMLDoc=Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.validateOnParse="false"
objXMLDoc.load(Server.MapPath(xmlFile))
if objXMLDoc.parseError.errorcode<>0 then
'error handling code
Response.write "Error code: " & objXMLDoc.parseError.errorCode & "<BR>"
Response.write "Position in file: " & objXMLDoc.parseError.filepos & "<BR>"
Response.write "Error text: " & objXMLDoc.parseError.reason & "<BR>"
else
' proceed
set oRoot = objXMLDoc.documentElement
Set NodeList = oRoot.getElementsByTagName("item-content")
'Set NodeListn = oRoot.nodeName
For Each Elem In NodeList
'If (Elem.firstChild.nodeValue = "Addictions articles") then
isNode = Elem.nodeName
If isNode = "html" then
'response.Redirect("testxmlhttp.asp?item=" & vItem)
xElment =Elem.text
response.Write("displaly Here")
response.write(xElment)
Else
xElment =Elem.text
response.redirect(xElment)
End if
Next
End if
%>
SOME OF THE XML FILES LOOKS LIKE THE FOLLOWING
---------sample1.xml-------------
<?xml version="1.0"?>
<!DOCTYPE SEND_ITEM_DETAILS>
<LIFE>
<item>
<item-id>9396</item-id>
<item-content> Group&SESSION=6767530564965005</item-content>
</item>
</life>
------- Sample2.xml ------------------------------------
<?xml version="1.0"?>
<!DOCTYPE SEND_ITEM_DETAILS>
<LIFE>
<item>
<item-id>11989</item-id>
<item-content>
<html>
<head>
<title>Relapse</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h4>
<font face="Arial, Helvetica, sans-serif" color="#324987">Question: When is
the most typical time that most smokers relapse when they try to stop?</font>
</h4>
<p><font face="Arial, Helvetica, sans-serif" size="2">The majority of smokers
relapse in the first few days (days 1-3). </font>
</p>
</body>
</html>
</item-content>
</item>
</life>
This is what I got..still having problems displaying te content...Thanks..
Any other suggestion on how to do this is welcome
Thanks,
-------- main.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<a href="getPage.asp?item=sample1.xml">sample1</a>
<a href="getPage.asp?item=sample2.xml">sample2</a>
</body>
</html>
-------- getPage.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim vItem
vItem = request.QueryString("item")
Dim objXMLDoc, xmlFile
xmlFile = vItem
Set objXMLDoc=Server.CreateObject("MSXML2.DOMDocument")
objXMLDoc.validateOnParse="false"
objXMLDoc.load(Server.MapPath(xmlFile))
if objXMLDoc.parseError.errorcode<>0 then
'error handling code
Response.write "Error code: " & objXMLDoc.parseError.errorCode & "<BR>"
Response.write "Position in file: " & objXMLDoc.parseError.filepos & "<BR>"
Response.write "Error text: " & objXMLDoc.parseError.reason & "<BR>"
else
' proceed
set oRoot = objXMLDoc.documentElement
Set NodeList = oRoot.getElementsByTagName("item-content")
'Set NodeListn = oRoot.nodeName
For Each Elem In NodeList
'If (Elem.firstChild.nodeValue = "Addictions articles") then
isNode = Elem.nodeName
If isNode = "html" then
'response.Redirect("testxmlhttp.asp?item=" & vItem)
xElment =Elem.text
response.Write("displaly Here")
response.write(xElment)
Else
xElment =Elem.text
response.redirect(xElment)
End if
Next
End if
%>
SOME OF THE XML FILES LOOKS LIKE THE FOLLOWING
---------sample1.xml-------------
<?xml version="1.0"?>
<!DOCTYPE SEND_ITEM_DETAILS>
<LIFE>
<item>
<item-id>9396</item-id>
<item-content> Group&SESSION=6767530564965005</item-content>
</item>
</life>
------- Sample2.xml ------------------------------------
<?xml version="1.0"?>
<!DOCTYPE SEND_ITEM_DETAILS>
<LIFE>
<item>
<item-id>11989</item-id>
<item-content>
<html>
<head>
<title>Relapse</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h4>
<font face="Arial, Helvetica, sans-serif" color="#324987">Question: When is
the most typical time that most smokers relapse when they try to stop?</font>
</h4>
<p><font face="Arial, Helvetica, sans-serif" size="2">The majority of smokers
relapse in the first few days (days 1-3). </font>
</p>
</body>
</html>
</item-content>
</item>
</life>