freelanceprogrammers.org Forum Index » PHP

Why is the XML output is encoded?


View user's profile Post To page top
luminousheart Posted: Tue Jun 21, 2005 12:10 am


Joined: 21 Jun 2005

Posts: 1
Why is the XML output is encoded?
It is our effort, to produce an xml file from an html content that
we parse. How can I stop PHP from encoding my html tags into &lts
and $gts?

To explain what we get now and what is desired, I am provided a
color-coded snippets of the xml files. The PHP code is also provided
for your critical eyes.


Thank you for your help in advance.


<pre >

<!â€"Bad form -->

<ProBody>

&lt;unsortedlist&gt;
&lt;list&gt;
&lt;anchor href="../news/pr_2005/rm_printing.html"&gt;Rocky Mountain
icecream Strengthens Short Run code Capabilities With my station
Nexress Optima Solution&lt;/anchor&gt;

&lt;/list&gt;&lt;list&gt;&lt;anchor
href="../news/pr_2005/cmm.html"&gt;wish to see this item
clear&lt;/anchor&gt;&lt;/list&gt;&lt;list&gt;&lt;anchor
href="../news/pr_2005/print1.html"&gt;same text goes here but not
showing 5634 DI System&lt;/anchor&gt;&lt;/list&gt;&lt;list&gt;

</ProBody>



<!â€"Desired form-->

<ProBody>

<list>
<anchor>Repeat some stuff here.</anchor>
</list>
<list>
<anchor>Some Anchor text goes here</anchor>
</list>
<list>
<anchor>PRINT1 DIRECT Saves Time, Reduces Waste With KPG
DirectPress 5634 DI System</anchor>
</list>

</ProBody>
</pre>

The code that produces the bad form is provided for your comments.

<code>
// Creates an instance of the DOMImplementation class
$imp = new DOMImplementation;
// Creates a DOMDocumentType instance
$DocTDT = $this->m_pageType;
$dtd = $imp->createDocumentType($DocTDT, ``, $DocTDT . `.dtd`);
// Creates a DOMDocument instance
$doc = $imp->createDocument("", "", $dtd);
// Set other properties
$doc->encoding = $this->xmlencoding;
if(trim($this->xmlstandalone) == `true`)
$doc->standalone = true;
else
$doc->standalone = false;
// we want a nice output
if($this->xmlformatOutput == `true`)
$doc->formatOutput = true;
else
$doc->formatOutput = false;
$root = $doc->createElement($this->xmlDocRoot);
// create titleNode with text
$titleNode = $doc->createElement($this->xmlTitle);
$titleNode = $root->appendChild($titleNode);
$titleNodeText = $doc->createTextNode($this->productTitle);
$titleNodeText = $titleNode->appendChild($titleNodeText);
// -- end of element
// Start Body Parsing
$this->RFText = getConverted2ClientTags($RFText);
echo "
Converted html tags to Client tags (i.e <td> to <cell>: " ,
$this->RFText;
echo "
";
// end Body Parsing
// create ProdBody with text
$bodyNode = $doc->createElement($this->xmlProdBody);
$bodyNode = $root->appendChild($bodyNode);
$bodyNodeText = $doc->createTextNode($this->RFText);
$bodyNodeText = $bodyNode->appendChild($bodyNodeText);
// -- end of element
$root = $doc->appendChild($root);
// if directory does not exist, create it.
$this->mkdirr($this->m_outDir, `0777`);
$this->m_outFile = $this->m_outDir. `/` .$this->m_outFile;
echo "
Wrote $this->m_outFile: " . $doc->save($this->m_outFile) . `
bytes` ."
";

</code>
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help