|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-04-07 16:30 UTC] hari_sayiri at rediffmail dot com
Description:
------------
I am posting a string from a vb.net pogram to a php program, the string is basically xml tags, i am able to get the string in php, but when u try to load the string using loadxml function i get the warning message
Warning: DOMDocument::loadXML() [function.loadXML]: Start tag expected, '<' not found in Entity
and so i am unable to retrieve the tag attributes and values.
Reproduce code:
---------------
$objDOM->loadXML($string);
where $string is <?xml version='1.0' encoding='UTF-8'?><map><mapsize size='2500 2500'/> </map>
Expected result:
----------------
i should get the attribute value into a variable by using dom functions
$map = $objDOM->getElementsByTagName("map")->item(0);
$mapsize = $map->getAttribute('size');
Actual result:
--------------
getting the above warning message and
Fatal error: Call to a member function getAttribute() on a non-object
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 17:00:01 2025 UTC |
<?php $objDOM = new DOMDocument(); $xml = $_POST['config']; $objDOM->loadXML($string); $map = $objDOM->getElementsByTagName("map")->item(0); $mapsize = $map->getAttribute('size'); echo $mapsize; ?>$objDOM = new DOMDocument(); $xml = "<?xml version='1.0' encoding='UTF-8'?><map><mapsize size='2500 2500'/> </map>"; $objDOM->loadXML($xml); $map = $objDOM->getElementsByTagName("mapsize")->item(0); $mapsize = $map->getAttribute('size'); var_dump($mapsize); ?> works for me perfectly.