Implementing HTML code via PHP XML Expat Parser
Posted: Wed Sep 09, 2009 12:46 pm
Hello,
I am trying to create a "journal" for my site. I figured that all the entries will be in xml format and then I'll just use the expat parser to simulate "individual" pages. However, I cannot seem to get my HTML tags to work.
[I patterned my expat parser from the one here: http://www.w3schools.com/php/php_xml_parser_expat.asp ]
So, my xml file has the structure resembling this:
title, date and content work out just fine. However, I am not entirely sure if my handling of p and i works. i does not work at all. p looks fine, that is, my text is grouped properly. One thing that makes me doubt the sanity of my p handling though is that, my stylesheet rules don't seem to apply to it.
This is how I handled the p and i tags in the start($parser,$element_name,$element_attrs) function of W3schools:
Can anyone point me to where I can learn how to handle my HTML tags well? W3schools tutorial is way too condensed. Thanks a lot.
I am trying to create a "journal" for my site. I figured that all the entries will be in xml format and then I'll just use the expat parser to simulate "individual" pages. However, I cannot seem to get my HTML tags to work.
[I patterned my expat parser from the one here: http://www.w3schools.com/php/php_xml_parser_expat.asp ]
So, my xml file has the structure resembling this:
Code: Select all
<title>Entry title</title>
<date>MM/DD/YY</date>
<content>
<p>Some text here.</p>
<p>And some more.</p>
<p>And some more.</p>
<p>Repeat until <i>fade</i>...</p>
</content>This is how I handled the p and i tags in the start($parser,$element_name,$element_attrs) function of W3schools:
Code: Select all
case "P";
echo "<p>";
echo "</p>"; //This is my attempt at generating clean HTML code. I haven't figured this one out much yet.
break;
case "I";
echo "<i>";
echo "</i>"; //Another attempt at generating clean HTML code. Again, I haven't figured this one out much yet.
break;