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

Urgent Please...xml ans asp

Status
Not open for further replies.

Kazzy

Programmer
Jul 21, 2003
20
0
0
US
HELP URGENT...Please please
ok, I am working with asp and xml.

I have hundreds of file similar to sample1 and sample2 (same xml structures). I am able to display the content of the xml file. However, what I am having problmes is with sample1. I want to be able to redirect to the link provided (as you see in sample1) when the <item-content> xml tags contains a link. If the xml file contains <html> tags (sample2) I want just to be able to display content.



Right now the pages below just display the content of the xml files.


--- 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>

---- 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" encoding="iso-8859-1"?>

<!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>



--- getPage.asp -------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<script>
//get parameter
var xTempItem
mainURL = window.location.search;
URLparts = mainURL.split('?');
Arguments = URLparts[1].split('&');

for (i in Arguments) {
pair = Arguments.split('=');
xTempItem = pair[1]
}

//get text
var strResponse
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("GET", xTempItem, false);
xmlhttp.send();
xmlhttp.responseText;
document.write(xmlhttp.responseText);

</script>
 
erm ...


don't use:

var xTempItem
mainURL = window.location.search;
URLparts = mainURL.split('?');
Arguments = URLparts[1].split('&');

for (i in Arguments) {
pair = Arguments.split('=');
xTempItem = pair[1]
}


use:

var xTempItem
xTempItem = Request.QueryString("item")


also

don't use:
xmlhttp.send();
xmlhttp.responseText;

you need to wait for a response,
use:
xmlhttp.send();
do while xmlhttp.readyState<>4

document.write(xmlhttp.responseText);

wouldn't it be better to include an xsl file to mark up the xml ?





 
I see thank you..I will do those changes...The problem is that I have hundreds of files similar structure sample1 & sample2. Many of the files are not well structure as you can see in the samples. Someone suggested to import it into a database...I am not that familiar with xml.

I tried to use xsl. It just give me errors...Right now I need to somehow redirect the pages ... while I learn on how to import it into database...please help....
 
If the "XML" files are not well-formed, you can't use XSL (if they are you can). Test well-formedness here:


Otherwise you'll have to use string manipulation and do something like test for "<html>".

Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top