xml with curly quotes?
Posted: Mon Oct 02, 2006 1:43 am
twigletmac | Please use
php product page:[/syntax]
this script yields the following errors unless I replace the &rsquo in <description> with a standard straight apostrophe ('). For some reason it doesnt mind using & which will always display as & when placed in the XML <description>
Warning: knives.xml:189: parser error : Entity 'rsquo' not defined in C:\Program Files\Apache Group\Apache2\htdocs\web_knives\prod1.php on line 13
Warning: Dan Burke Gentleman’s Folder Dan's work speaks for itself. Just a perfect in C:\Program Files\Apache Group\Apache2\htdocs\web_knives\prod1.php on line 13
Warning: ^ in C:\Program Files\Apache Group\Apache2\htdocs\web_knives\prod1.php on line 13
Warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Group\Apache2\htdocs\web_knives\prod1.php on line 28
twigletmac | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Trying to figure out a way to parse XML using simplexml_load_file and curly quotes/apostrophes can anyone help?
example:
xml:
[syntax="xml"]
<knife>
<maker>Dan Burke</maker>
<type>Folder</type>
<named>no</named>
<price>599</price>
<shipping>2</shipping>
<description>
Dan Burke Gentleman’s Folder Dan's work speaks for itself. Just a perfect carry size, wonderful fit and finish and truly remarkable Scales backed by Gold Foil.
</description>
<thumb>./images/thm_burkeFolder.jpg</thumb>
<image1>./images/burkeFolder.jpg</image1>
<image2></image2>
<image3></image3>
<image4></image4>
<image5></image5>
<image6></image6>
<featured>no</featured>
<reduced>no</reduced>
</knife>
Code: Select all
<?php
$xml = simplexml_load_file('knives.xml');
$per_row = 6;
echo '
<table cellpadding="0" border="0" cellspacing="0">';
$count = 0;
for($x = 0; $x < count($xml); $x++)
{
if($count == 0)
{
echo '
<tr>';
}
foreach($xml -> knife as $knife){
if($knife->price < 1000 && $knife->price > 1){
$type=stripslashes($knife->type);
echo "<td class=\"product\" align=\"center\" valign=\"bottom\" height=\"116\">
<div height=\"116\">
<a href=\"detail.php?image1=$knife->image1\" target=\"_self\">
<img src=\"$knife->thumb\" alt=\"$knife->maker custom knife\">
</a>
</div>
<br><span class=\"maker\">$knife->maker</span><br>";
if($knife->named=="no"){
echo"$type";
}else{
echo "“$type”";}
echo"
<br>$$knife->price.
<br><br>
<a href=\"http://ww8.aitsafe.com/cf/add.cfm?userid=something&product=$knife->maker $knife->type&price=$knife->price&units=$knife->shipping&return=www.exquisiteknives.com\" class=\"button\" target=\"_blank\">Add to Cart</a><br><br>
</td>";
$count++;
if(($count == $per_row) || ($xml[$x] == end($xml)))
{
echo '</tr>';
$count = 0;
}
}
}
echo '
</table>';
exit;
}
?>Warning: knives.xml:189: parser error : Entity 'rsquo' not defined in C:\Program Files\Apache Group\Apache2\htdocs\web_knives\prod1.php on line 13
Warning: Dan Burke Gentleman’s Folder Dan's work speaks for itself. Just a perfect in C:\Program Files\Apache Group\Apache2\htdocs\web_knives\prod1.php on line 13
Warning: ^ in C:\Program Files\Apache Group\Apache2\htdocs\web_knives\prod1.php on line 13
Warning: Invalid argument supplied for foreach() in C:\Program Files\Apache Group\Apache2\htdocs\web_knives\prod1.php on line 28
twigletmac | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]