Reputation: 46
I am having a headache trying to parse XML files.
Previously, my script to open and parse XML files has worked flawlessly. However, today I noticed it was not working correctly so I took a look.
My XML files are uniquely formatted. Unfortunately I cannot show an example of those. When I looked into the issue though, I realized they were being improperly read by PHP. Instead of reading the entire file into a string, it strips the XML tags and only takes in the values between those tags. I have no idea why it is doing this.
Not much example code:
echo file_get_contents(URL_TO_FILE);
Upvotes: 0
Views: 164
Reputation: 1553
<?php
$xml=simplexml_load_file("note.xml");
print_r($xml);
?>
Sounds like you are viewing the xml in an html reader (browser). This will ignore the tags of course. Be sure you are viewing the source.
Upvotes: 4