Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
January 17, 2006, 8:46 pm
rate this thread
<?xml version="1.0" encoding="UTF-8" ?>
<blah id="1">Om du vet hur många gånger blivit jag trevligt
överkritisk på jättekult bajset!</blah>
I am trying to simply read it using tree-based XML functions in PHP
which I know (sorry, don't know or quickly understand DOM though that
might be a better option if someone wants to tutor me in it):
$fileID = @fopen($_SERVER['DOCUMENT_ROOT'] . '/stuff.xml', 'rb'); //
$contents = @fread($fileID, filesize($_SERVER['DOCUMENT_ROOT'] .
'/stuff.xml')); // $contents HAS THE ENTIRE XML CONTENTS
@fclose($fileID); // NO PROB
$parser = xml_parser_create(); // WORKS JUST FINE
xml_parse_into_struct($parser, $contents, $xmlArray, $tags); //
$xmlArray and $tags are both empty arrays! But why?
This seems to happen with PHP versions 4.1.2 - 5.0.4 with me trying to
work with a UTF-8 encoded XML script created in the following manner:
1. Using Windows XP Notepad, wrote script
2. Saved as "stuff.xml" using UTF-8 encoding as I'm saving it
3. Verified well-formed XML by opening in both Firefox and IE
Is there something missing or just not right here, or the worst-case
scenario: PHP can't read UTF-8-encoded XML in at least tree form?
This affects one particular site that has no access to a DB that
utilizes simple data in XML format, however, the data may contain
- R. Rajesh Jeba Anbiah
January 18, 2006, 4:51 am