0

I have a php file which generates and echo's XML data.

So basically it shows a XML but it's a PHP file.

I need to read and parse this data.

I've seen this: simplexml_load_file('some.xml'); but in this case I cannot do this as I've got the xml as a php file.

How can I do this?

2
  • You have to store the XML content is a var if you want to parse it after Commented Mar 5, 2013 at 11:08
  • I believe this is an answer you are looking for: stackoverflow.com/a/8693175/1051764 Commented Mar 5, 2013 at 11:11

2 Answers 2

1

Just the same way, the file extension doesn't matters (.xml or .php) what it really matters is the actual contents of the file, so if your file have a .php extension but its contents are valid xml then you should have no problem:

simplexml_load_file('somepage.php');  //this is fine
Sign up to request clarification or add additional context in comments.

2 Comments

I'm getting: Warning: simplexml_load_file() ... Start tag expected, '<' not found in ...Any ideas why?
Then your php is not outputting valid xml data, paste the contents on pastebin.com and paste the link here so we can take a look at it.
0

Set mime type to xml header('Content-Type:text/xml');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.