...

View Full Version : To XML or NOT to XML that is my question.



StupidRalph
02-23-2006, 04:09 AM
I am building a static site. I want this said static site to have search capabilities This site has a database for the company's extranet, but I do not want to use the database b/c it has sensitive info (i.e.- company policy, protocol and things of that nature but sensitive none the less.) just to have search capabilities. So my question is how would I go about building this site? Would it be to build a content XML file for each page and wrap that content with the sites template? Any light that anyone can shed on this will be great.

StupidRalph
02-23-2006, 05:07 AM
I have read up on XML and I undestand how it is from a computer's standpoint how it is better.
ex.


<p>
Age: 25<br />
Name: Micheal<br />
Department: Shipping
</p>
could be expressed better to a computer by saying


<age>25</age>
<name>Micheal</name>
<department>Shipping</department>

But I'm not quite sure how this will help me in this situation.

I am still reading up on this. I think I am on the right track reading about Data islands.

StupidRalph
02-23-2006, 10:23 PM
Okay so I scraped the Data Island idea and went ahead and started parsing my XML file with javascript.


<script type="text/javascript">
var xmlDoc
function loadXML()
{
//load xml file
// code for IE
if (window.ActiveXObject)
{
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load("site.xml");
getmessage()
}
// code for Mozilla, etc.
else if (document.implementation &&
document.implementation.createDocument)
{
xmlDoc= document.implementation.createDocument("","",null);
xmlDoc.load("site.xml");
xmlDoc.onload=getmessage
}
else
{
alert('Your browser cannot handle this script');
}
}function getmessage()
{
document.getElementById("content_header").innerHTML=
xmlDoc.getElementsByTagName("content_header")[0].firstChild.nodeValue
document.getElementById("content").innerHTML=
xmlDoc.getElementsByTagName("content")[0].firstChild.nodeValue
}
</script>

Here is the XML file I am going to be using.

<?xml version="1.0" encoding="iso-8859-1"?>
<page id="1">
<name>Home</name>
<title>Company Name</title>
<content_header> Our Company</content_header>
<content>
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</content>
</page> and finally this is the html page which brings it all together.

<html><head><title>Company Site</title></head>
<body onLoad="loadXML()">
<!--Container tag needed to center divs in IE (IE HACK)-->
<div class="IEcontainer">
<!--Container tag-->
<div id= "" class="container">
<div id="content_header"> Content Header</div>
<div id="content">Content goes here</div>
<!--End Container tag-->
</div>
<!--End IE HACK container tag-->
</div>
</body>
</html>
I keep checking and double checking my code but I keep getting an error on line 30 first character. Object Required. So what is it not loading my XML file? That would be
document.getElementById("content_header").innerHTML=
xmlDoc.getElementsByTagName("content_header")[0].firstChild.nodeValue Now I am pretty familiar with the innerHTML and innerText methods but I am at my wits end with this. Anyone out there?

StupidRalph
02-24-2006, 02:19 AM
Okay the my javascript works I just had internal problems with my path. So this will parse it and handle everything. :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum