Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts

    To XML or NOT to XML that is my question.

    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.
    Last edited by StupidRalph; 02-23-2006 at 04:15 AM.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    I have read up on XML and I undestand how it is from a computer's standpoint how it is better.
    ex.
    Code:
    <p> 
    Age: 25<br />
    Name: Micheal<br />
    Department: Shipping
    </p>
    could be expressed better to a computer by saying
    Code:
    <age>25</age>
    <name>Micheal</name>
    <department>Shipping</department>
    But I'm not quite sure how this will help me in this situation.

    Edit: I am still reading up on this. I think I am on the right track reading about Data islands.
    Last edited by StupidRalph; 02-23-2006 at 06:41 AM.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #3
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts

    Parsing w/ Javascript

    Okay so I scraped the Data Island idea and went ahead and started parsing my XML file with javascript.

    Code:
    <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.
    Code:
    <?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.
    Code:
    <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
    Code:
    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?
    Last edited by StupidRalph; 02-23-2006 at 10:48 PM.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #4
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Okay the my javascript works I just had internal problems with my path. So this will parse it and handle everything.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •