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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Markup Validation W3C

    im trying validate this html which contains javascript, i cant seem to work out what to change to make it correctly validated, there are several different kind of parsing errors and another few things, the page loads and appears fine tho:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Oil Producing and Consuming Countries</title>
    <link rel="stylesheet" href="oil_style.css"/>
    <script type="text/javascript">
    function readXML()
    {var paraText ;
     var newRow ;
     var newPara ;
     var newCell ;
    
     var xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
     xmlDoc.async="false"
     xmlDoc.load("oil_2.xml")
    
     var country_producer = xmlDoc.getElementsByTagName("country_producer")
     var theTable = document.getElementById("producertable")
     var theTableBody = document.createElement("tbody")
     
    
     for(var i=0; i<country_producer.length;i++) 
     {newRow = document.createElement("tr")  
      paraText= document.createTextNode(country_producer[i].getElementsByTagName("name")[0].firstChild.nodeValue)
      newPara = document.createElement("p")  
      newPara.appendChild(paraText)          
      newCell = document.createElement("td") 
      newCell.appendChild(newPara)           
      newRow.appendChild(newCell)            
      paraText= document.createTextNode(country_producer[i].getElementsByTagName("produces")[0].firstChild.nodeValue)
      newPara = document.createElement("p")
      newPara.appendChild(paraText)
      newCell = document.createElement("td")
      newCell.appendChild(newPara)
      newRow.appendChild(newCell)
      theTableBody.appendChild(newRow)       
      paraText= document.createTextNode(country_producer[i].getElementsByTagName("supplies")[0].firstChild.nodeValue)
      newPara = document.createElement("p")
      newPara.appendChild(paraText)
      newCell = document.createElement("td")
      newCell.appendChild(newPara)
      newRow.appendChild(newCell)
      theTableBody.appendChild(newRow)       
      
     }
     theTable.appendChild(theTableBody)      
    }
    </script>
    
    </head>
    
    <body onload="readXML()">
    <div class="page_header">
    <h1>Top Ten Oil Producing Countries</h1>
    </div>
    <div>
    <table class="oil_data_table" id="producertable" width="400px" border="2px">
    <tr class="oil_data_table_headers">
    	<td>Producer</td>
    	<td>Amount</td>
    	<td>Supplier To:</td>
    </tr>
    </table>
    </div>
    
    <table class="next" width="700px" border="0px">
    <tr>
    	<td></td>
    	<td></td>
    	<td><a href="javascript2.html">next</a></td>
    </tr>
    </table>
    
    </body>
    </html>

  • #2
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    You need to surround your script with CDATA islands when you are serving your page as XHTML.

    Alternatively, making your script external will get you out of all your validation woes.

    For further reading:
    https://developer.mozilla.org/En/Pro...HTML_Documents
    http://javascript.about.com/library/blxhtml.htm
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph


  •  

    Posting Permissions

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