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

xml - redirecting page/displaying content

Status
Not open for further replies.

Kazzy

Programmer
Jul 21, 2003
20
US
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>
 
What doesn't work in your code : html content, redirection, both ?

Water is not bad as long as it remains outside human body ;-)
 
I am having problem displaying the content!! Also, Is this the best of doing this? My goal is to display content if <html> tags are present on xml file or redirect if <item-content> containts webaddress....thanks
 
To me you're acting the good way.
So, when "item-content" node contains an URL, everithing works allright ?
But what happen when "item-content" node contains HTML : Nothing ? a Blank page ?

Water is not bad as long as it remains outside human body ;-)
 
Nothing ?
A Blank page ?
If so, use popup menu to display page source to check if it's really empty or just malformed HTML. For example, the problem should be ASP server encoding all tags delimiters (">" to "&gt;& and "<" to "&lt;").

Water is not bad as long as it remains outside human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top