1

I'm not very experienced when it comes to XML, I'm looking for a simple php code that can display certain information from an XML file. This file to be exact:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <TITLE>THIS</TITLE>
    <TITLE2>THIS AGAIN</TITLE2>
</Response>

Any help would be great, Thanks!

(P.S I just want to simply echo the 2 fields out)

3

1 Answer 1

3

Take a look at simplexml, it's pretty easy and straight forward!

Your example would look like this:

$xml = simplexml_load_string($xml_string);

echo $xml->title;
echo $xml->title2;
Sign up to request clarification or add additional context in comments.

1 Comment

if it is a file look at simplexml_load_file

Your Answer

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