How to use an XML string to find certain element values in php?

How to use an XML string to find its certain element values? i used this code:

    10: $php_var = json_decode($json, 1);
    11  $serializer=new XML_Serializer();
    12: if($serializer->serialize($php_var))
    13: xml_string=htmlspecialchars($serializer->getSerializedData()); 
    14: echo $xml_string;
    15: $xml_obj = new DOMDocument();
    16: $xml_obj->loadXML($xml_string);
    17: $urls=$xml_obj->getElementsByTagName('url');

but it doesnt work and i got a Warning: DOMDocument::loadXML() [domdocument.loadxml]: Start tag expected, '<' not found in Entity, line: 1 in /var/www/seo-tool/get_details.php on line 15


What's that htmlspecialchars()? that function converts all the < and > to &lt; and &gt; and the xml is no longer xml.

Remove that call. if you want to echo the XML, do echo htmlspecialchars($xml_string) but don't store it in the variable.

Old was: The XML you posted seems to be valid.

But you are missing the XML declaration, at the beginning of the string:

<?xml version="1.0" encoding="UTF-8" ?>

Need Your Help

Android upload to store error - file is invalid: ERROR getting 'android:name' attribute:

android upload store

I am uploading my draft application .apk file myapp.apk to When I click upload I get the error message:

Select first instance only with XPath?

xml xpath

I am parsing some XML something like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.