tannu
06-26-2007, 02:14 PM
Hello all,
I am having a PHP script that generates the xml using the data in a mysql database. We have "nl2br" function in PHP that preserves the format (<br /> <p> etc..). When i use this method to generate the xml, the xml file that gets generated contains the <br /> tag in the node tree. Is there any other way to preserve the format even in the generated xml, without having the <br /> tags.
Following is the PHP:
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("xplane");
$query = "SELECT * FROM categorythreads";
$result = mysql_query($query);
header("Content-type: text/xml");
$xml = "<?xml version='1.0' encoding='utf-8'?>";
$xml .= "<category>";
while($fetchedThreads = mysql_fetch_object($result))
{
$xml .= "<threads>";
$xml .= "<threadID>" .$fetchedThreads -> threadID. "</threadID>";
$xml .= "<threadCategory>" .$fetchedThreads -> threadCategory ."</threadCategory>";
$xml .= "<threadTitle>" .$fetchedThreads -> threadTitle ."</threadTitle>";
$xml .= "<threadDetails>" .$fetchedThreads -> threadDetails ."</threadDetails>";
$xml .= "<postedDate>" .$fetchedThreads -> postedDate ."</postedDate>";
$xml .= "<permaLink>" .$fetchedThreads -> permaLink ."</permaLink>";
$xml .= "</threads>";
}
$xml .= "</category>";
echo nl2br($xml);
mysql_free_result($result);
mysql_close();
?>
generated xml:
<category>
<threads>
<threadDetails>"I typically use this column to look at future trends."
<br />
"I typically use this column to look at future trends."</threadDetails>
</threads>
</category>
Javascript statement that places the nodevalue:
var threadDetails = result.getElementsByTagName("threadDetails")[i].firstChild.nodeValue;
document.getElementById("thread").innerHTML = threadDetails;
html:
<div id="thread">"I typically use this column to look at future trends."</div>
expected html:
<div id="thread">
"I typically use this column to look at future trends."
"I typically use this column to look at future trends."
</div>
please do help me out,
thanks in advance,
tannu
I am having a PHP script that generates the xml using the data in a mysql database. We have "nl2br" function in PHP that preserves the format (<br /> <p> etc..). When i use this method to generate the xml, the xml file that gets generated contains the <br /> tag in the node tree. Is there any other way to preserve the format even in the generated xml, without having the <br /> tags.
Following is the PHP:
<?php
mysql_connect("localhost", "root", "");
mysql_select_db("xplane");
$query = "SELECT * FROM categorythreads";
$result = mysql_query($query);
header("Content-type: text/xml");
$xml = "<?xml version='1.0' encoding='utf-8'?>";
$xml .= "<category>";
while($fetchedThreads = mysql_fetch_object($result))
{
$xml .= "<threads>";
$xml .= "<threadID>" .$fetchedThreads -> threadID. "</threadID>";
$xml .= "<threadCategory>" .$fetchedThreads -> threadCategory ."</threadCategory>";
$xml .= "<threadTitle>" .$fetchedThreads -> threadTitle ."</threadTitle>";
$xml .= "<threadDetails>" .$fetchedThreads -> threadDetails ."</threadDetails>";
$xml .= "<postedDate>" .$fetchedThreads -> postedDate ."</postedDate>";
$xml .= "<permaLink>" .$fetchedThreads -> permaLink ."</permaLink>";
$xml .= "</threads>";
}
$xml .= "</category>";
echo nl2br($xml);
mysql_free_result($result);
mysql_close();
?>
generated xml:
<category>
<threads>
<threadDetails>"I typically use this column to look at future trends."
<br />
"I typically use this column to look at future trends."</threadDetails>
</threads>
</category>
Javascript statement that places the nodevalue:
var threadDetails = result.getElementsByTagName("threadDetails")[i].firstChild.nodeValue;
document.getElementById("thread").innerHTML = threadDetails;
html:
<div id="thread">"I typically use this column to look at future trends."</div>
expected html:
<div id="thread">
"I typically use this column to look at future trends."
"I typically use this column to look at future trends."
</div>
please do help me out,
thanks in advance,
tannu