Hi guys,
I have got an XML file that has been created using PHP, and I am now trying to read the file back in. The problem is that where I have replaced HTML special characters using htmlspecialchars, when i read this back in I get what appears to be a line break.
So if in the XML document I have got something like this:
Liverpool's Players
When I come to read it back out from the XML document I get:
Liverpool
'
s Players
i'm using the usual XML reading code
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement"
;
xml_set_character_data_handler($xml_parser, "characterData"
;
if (!($fp = fopen($file, "r"
)) {
die("could not open XML input"
;
}//if
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
$ErrorMessage = "An error has occured while importing the XML data.";
$ErrorMessage = $ErrorMessage . "The XML file that was being imported was $file";
}//if
}//while
xml_parser_free($xml_parser);
and this is the code that I am using to output the ThemeName
} else if (($NodeName == 'THEMENAME') && (Trim($data) != '')) {
echo nl2br($data) . "<BR>";
$ThemeName = AddSlashes($data);
At the moment this is the only one that I am looking at but I am assuming that all of the other elements in the xml document are going to have the same problem. I am using PHP 4.3.1 on a win2k server.
Any helps would be appreciated
Tony
I have got an XML file that has been created using PHP, and I am now trying to read the file back in. The problem is that where I have replaced HTML special characters using htmlspecialchars, when i read this back in I get what appears to be a line break.
So if in the XML document I have got something like this:
Liverpool's Players
When I come to read it back out from the XML document I get:
Liverpool
'
s Players
i'm using the usual XML reading code
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement"
xml_set_character_data_handler($xml_parser, "characterData"
if (!($fp = fopen($file, "r"
die("could not open XML input"
}//if
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
$ErrorMessage = "An error has occured while importing the XML data.";
$ErrorMessage = $ErrorMessage . "The XML file that was being imported was $file";
}//if
}//while
xml_parser_free($xml_parser);
and this is the code that I am using to output the ThemeName
} else if (($NodeName == 'THEMENAME') && (Trim($data) != '')) {
echo nl2br($data) . "<BR>";
$ThemeName = AddSlashes($data);
At the moment this is the only one that I am looking at but I am assuming that all of the other elements in the xml document are going to have the same problem. I am using PHP 4.3.1 on a win2k server.
Any helps would be appreciated
Tony