View Full Version : ASP and XML
Hello,
well i'm a noob to XML and ASP...
i have looked at some tutorials, and i learned a little from them... :clap:
let say a XML file lets called it "xmlfile.xml"
looks like this:
<?xml version="1.0"?>
<root>
<question>
<text> this is the first question </text>
<answer correct = false > this is answer 1, <message> this is incorrect</message>
</answer>
<answer correct = false > this is answer 2, <message> this is incorrect</message>
</answer>
<answer correct = true> this is answer 3, <message> this is correct</message>
</answer>
</question>
and so on...
What i want to do, is make a program web based using ASP, (no C#, or ASP.net)
that will read this XML file
and view the question in a textbox and under the question is the 3 different answer and beside them the message and in a another textbox the "Correct value" ( also in textfile )
what do you recommand me to do, and do you think i should clean up the XML?
please help....
this is only the first part of this web app.... then i have to find a way to add more question and answer from the web page..... (newb)
superklye
10-28-04, 07:32 PM
I don't know the answers to your questions, but I do know that http://www.w3schools.com is an excellent resource with all sorts of tutorials for all kinds of web programming and the like. check them out if you haven't already.
i have but i will look again...thanx...
I was going to jump in with some help for you with C# and ASP.NET...but classic ASP huh?
Well here are some really good links to directly help you, I believe...
http://msdn.microsoft.com/library/en-us/dnxml/html/beginner.asp
http://www.stardeveloper.com/articles/display.html?article=2000072801&page=1
http://p2p.wrox.com/topic.asp?TOPIC_ID=10071
http://p2p.wrox.com/topic.asp?TOPIC_ID=840
http://www.freevbcode.com/ShowCode.asp?ID=2745
http://www.forum4designers.com/message133845.html
Look at the last two posts on this page in particular:
http://forums.aspfree.com/archive/t-27983
You can find many more results from my Google search on this question (http://www.google.com/search?q=reading+xml+with+asp+-asp.net+-.net&hl=en&lr=&start=20&sa=N).
Good luck! :cool:
thank you,
well i know classic asp.:D
thank you,
well i know classic asp.:D
Oh I didn't mean what I said in a bad way. :) If something works, stick with it if you have no compelling reason to change. Too many people change just for the sake of changing. Good luck! :)
here is my CODE from the page that gets the XML:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var nds=0;
function add()
{
nds++;
if (nds>=3)
{
nds=3;
}
document.form1.textfield10.value = nds;
showdata();
}
function subt()
{
nds--;
if (nds<=0)
{
nds=0;
}
document.form1.textfield10.value = nds;
showdata();
}
</script>
<script type="text/javascript">
//for="window" event="onload"
var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("conceptquiz.xml");
var ans=1,msg=2,q_num;
nodes=xmlDoc.documentElement.childNodes;
var loop,loop2;
loop=nodes.length;
loop2=xmlDoc.documentElement.childNodes(x).length;
var x=0,y=0;
function count()
{
for(n=x;n<x+1;n++)
{
//my_div.innerHTML =my_div.innerHTML+my_div1.innerHTML+my_div2.innerH TML+my_div3.innerHTML+' <br>'+nodes.item(x).childNodes(0).text;
my_div.innerHTML='<hr><br>'+my_div.innerHTML+nodes.item(x).childNodes(0).tex t+'<br>';
//for (y=0;y<4;y++)
while(y!=4)
{
//my_div1.innerHTML =my_div1.innerHTML+'<b> Answer: </b>'+nodes.item(question_num).childNodes(ans).text ;//+ '<br> '+ my_div2.innerHTML+"<b>Message </b> "+ nodes.item(question_num).childNodes(msg).text+' '+my_div3.innerHTML+"<br><b>Correct? </b> "+ nodes.item(question_num).childNodes(ans).getAttrib ute("correct")+'<br><br>';
//my_div1.innerHTML+nodes.item(x).childNodes(0).text
my_div1.innerHTML =my_div1.innerHTML+'<p></p><b> Answer: </b>'+ nodes.item(x).childNodes(ans).text + my_div2.innerHTML+'<b><br> Message: </b>'+ nodes.item(x).childNodes(msg).text +'<b> <br>Correct? </b>'+ nodes.item(x).childNodes(ans).getAttribute("correct")+'<br /><hr>' ;
//my_div2.innerHTML = my_div2.innerHTML+'<b>Message: </b>'+ nodes.item(x).childNodes(msg).text;
//my_div3.innerHTML = my_div3.innerHTML+'<b>Correct? </b>'+ nodes.item(x).childNodes(ans).getAttribute("correct")+'<br>';
ans=ans+2;
msg=msg+2;
y++;
}
}
}
function add2()
{
ans =1;
msg =2;
y=0;
x++;
count();
}
</script>
</head>
<body onLoad="count()">
<div id="my_div"></div>
<div id="my_div1" ></div>
<div id="my_div2"></div>
<div id="my_div3">
<form name="form1" method="post" action="">
<input type="button" name="Button" value="Button" onClick="add2()">
</form>
</div>
</body>
</html>
how could i make this to be show in this format... in a table
Question 1
answer 1 message 1 correct 1
answer 2 message 2 correct 2
answer 3 message 3 correct 3
answer 4 message 4 correct 4
and continue to X number of questions....
If I follow you correctly, you would just put the necessary HTML to generate your table(s) within an ASP loop whose count is tied the number of questions you have (referred to as nQuestions below).
Question for you, what are the variables loop and loop2 for? You declare/assign them but never use them.
Some quick pseudocode to demonstrate what I mentioned above would be:
<html>
<body>
<table>
<%
For i = 1 To nQuestions
Response.Write "<tr><td colspan=3><b>Question " + CStr(i) + "</b><br></td></tr>"
For j = 1 To 4
Response.Write "<tr><td>answer " + CStr(j) + "</td><td>message " + CStr(j) + "</td><td>correct " + CStr(j) + "</td></tr>"
Next
Next
%>
</table>
</body>
</html>
Thank you....for your help,
Last problem solved... thank you :D
although i know this is not my last... :D
vBulletin® v3.7.1, Copyright ©2000-2010, Jelsoft Enterprises Ltd.