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

Bit shift and convert character to unicode escape string

java hex bit

I found a java class that convert byte or char to hexadecimal value. But I cannot understand the code clearly. Can you explain what the code do or where I can find more resources about this?

OSGI missing requirement error

java osgi glassfish-3 apache-felix

I am new to OSGI and I am trying to figure out how I resolve errors such as the one below

passing NSManagedObjects between ViewControllers - random bad access errors

iphone objective-c ipad

Is passing NSManagedObjects between ViewControllers a bad idea? I have an iPad app and I seem to run into random bad access crashes and sigbart errors.

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.