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

xml problem

Status
Not open for further replies.

jvdboom

Programmer
Aug 18, 2002
93
BE
It's not real problem but my question is :for example:
<i>something<b>bold</b>something else</i>
I can't know the that bold is between something and something else how can this be done
sorry that it's mainly dutch.
------------------
//alert('test');
/*
Geschreven door Jan van den Boom
Copyrighted door Jan van den Boom
Dit script zet een xmldocument om in een gewenste vorm
Dit script hoort best in een extern .js bestand omdat anders dit script bij elke pageview gedownload word.
Syntax voor een link naar een bepaald xml-item: word er niets of geen .xml document na het vraagteken opgegegen word de standaard ingestelde pagina geladen


aanpassingen enkel toegelaten vanaf volgende regel */
var uit;var titel;var achtergkleur;var tekstkleur;var hoofdtitel;var docnaam;var standaardpag;var url;var label;var URLindex;var loopindex;//declaratie
titel = &quot;Nieuws&quot;;
achtergkleur=&quot;#EFEAEF&quot;;
tekstkleur=&quot;#000000&quot;;
hoofdtitel=&quot;Nieuws&quot;;
standaardpag=&quot;newt.xml&quot;;//standaard ingestelde pagina(default)
//einde aanpassingsgebied
//wijzig niets vanaf hier

if (location.search.substring(1).indexOf('.xml')!=-1){docnaam=location.search.substring(1)} else {docnaam=standaardpag}
//alert(docnaam);
uit = &quot;<html><head><title>&quot; + titel + &quot;</title><meta http-equiv='Content-Type content=text/html; charset=iso-8859-1'></head><body bgcolor=&quot; + achtergkleur + &quot; text=&quot; + tekstkleur + &quot;><div align=center><h1>&quot; + hoofdtitel + &quot;</h1><br>&quot;;
importXML();
function importXML()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument(&quot;&quot;, &quot;&quot;, null);
xmlDoc.onload = Startloading;
}
else if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject(&quot;Microsoft.XMLDOM&quot;);
xmlDoc.onreadystatechange = tmp;
}
else
{
alert('Sorry, Uw browser kan dit script niet aan.');
return;
}
xmlDoc.load(docnaam);
}

function tmp()
{
if (xmlDoc.readyState == 4) Startloading();
}

function opmaak(noden)
{
var nodenaam = noden.nodeName;
var nodeinh = noden.text;
var huit = &quot;&quot;;
var reuit;
switch(nodenaam)
{

case &quot;pic&quot;:
huit = &quot;<img src=\&quot;&quot; + nodeinh + &quot;\&quot;>&quot;;
break;
case &quot;onder&quot;:
huit = &quot;<u>&quot; + nodeinh + &quot;</u>&quot;;
break;
case &quot;vet&quot;:
huit = &quot;<b>&quot; + nodeinh + &quot;</b>&quot;;
break;
case &quot;cursief&quot;:
huit = &quot;<i>&quot; + nodeinh + &quot;</i>&quot;;
break;
case &quot;br&quot;:
huit = &quot;<br>&quot;;
break;
case &quot;link&quot;:
var nodeurlcount=noden.childNodes.length;
url=null;label=null;

for(URLindex=0;URLindex<nodeurlcount;URLindex++)
{
switch(noden.childNodes.item(URLindex).nodeName)
{

case &quot;url&quot; :
url = noden.childNodes.item(URLindex).text;
break;
case &quot;label&quot;:
label = noden.childNodes.item(URLindex).text;
break;
default:
reuit = opmaak(noden.childNodes.item(URLindex));
break;
}

}
if (label==null){label=url}
if (reuit!=null){label=reuit}
if (url==null){huit = &quot;fout&quot;} else {huit = huit + &quot;<a href=\&quot;&quot; + url + &quot;\&quot; target=\&quot;_self\&quot;>&quot; + label + &quot;</a>&quot;}
break;
}
return(huit);
}

function Startloading()
{
var RootElement1;
var loopindex;
var vraag;

vraag=0;
var antwoord;
var CurrentNode;

RootElement1=xmlDoc.documentElement;
if(RootElement1==null)
{
uit = uit + &quot;<font color=red><b>De gegevens van het XML bestand kan niet worden opgehaald</b></font>&quot;;
}
else
{
var nodecount=RootElement1.childNodes.length;
// uit = uit + RootElement1.nodeName;
//uit = uit + location.search.substring(1)
switch(RootElement1.nodeName)
{
case &quot;quiz&quot;:
uit = uit + &quot;<p align=left><form name=quiz1 method=POST action=/cgi-bin/quiz.cgi>&quot;;
break;
}

for(loopindex=0;loopindex<nodecount;loopindex++)
{

CurrentNode=RootElement1.childNodes.item(loopindex);
switch(RootElement1.nodeName)
{
case &quot;quiz&quot;:

switch(CurrentNode.nodeName)
{
case &quot;vraag&quot;:
vraag++;
antwoord=0;
uit = uit + &quot;<b>Vraag &quot; + vraag + &quot; : &quot; + CurrentNode.text + &quot;</b><br>&quot;;
break;
case &quot;antwoord&quot;:

antwoord++;
uit = uit + &quot;<input type=radio name=vr&quot; + vraag + &quot; value=&quot; + antwoord + &quot;>Mogelijkheid &quot; + antwoord + &quot; : &quot; + CurrentNode.text + &quot;<br>&quot;;
break;

}
break;
case &quot;nieuws&quot;:
switch(CurrentNode.nodeName)
{
case &quot;titel&quot;:

uit = uit + &quot;<h3>&quot; + CurrentNode.text + &quot;</h3>&quot;;
break;
case &quot;inleiding&quot;:

uit = uit + &quot;<i>&quot; + CurrentNode.text + &quot;</i>&quot;;
break;
case &quot;middel&quot;:

uit = uit + CurrentNode.text;
break;
case &quot;slot&quot;:

uit = uit + &quot;<b>&quot; + CurrentNode.text + &quot;</b>&quot;;
break;
case &quot;br&quot;:
uit = uit + &quot;<br>&quot;;
break;

default:
uit = uit + opmaak(CurrentNode);
break;
}
break;
}


}
}
switch(RootElement1.nodeName)
{
case &quot;quiz&quot;:
uit = uit + &quot;<input type=hidden name=vr value=&quot; + vraag + &quot;><input type=hidden name=quiz value=quiz1><br><input type=submit value=Verzenden></form></p>&quot;;
break;
case &quot;nieuws&quot;:
uit = uit + &quot;<br><br><a href=\&quot;nieuws.htm?&quot; + standaardpag + &quot;\&quot; target=\&quot;_self\&quot;>Terug naar overzicht</a>&quot;;
break;
}

uit = uit + &quot;</div></body></html>&quot;
//alert(uit);
document.write(uit);


}
---------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top