php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37010 error while loading a string into dom object
Submitted: 2006-04-07 16:30 UTC Modified: 2006-04-07 18:20 UTC
From: hari_sayiri at rediffmail dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.1.2 OS: windows 200
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hari_sayiri at rediffmail dot com
New email:
PHP Version: OS:

 

 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-07 16:36 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.

Cannot reproduce.
 [2006-04-07 16:55 UTC] hari_sayiri at rediffmail dot com
<?php
$objDOM = new DOMDocument();

$xml = $_POST['config'];
$objDOM->loadXML($string);
$map = $objDOM->getElementsByTagName("map")->item(0);
$mapsize =  $map->getAttribute('size');
echo $mapsize;
?>
 [2006-04-07 17:04 UTC] tony2001@php.net
>$xml = $_POST['config'];

Could you please provide _complete_ script, that doesn't use any external data etc. ? Thanks.
 [2006-04-07 17:15 UTC] chregu@php.net
$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.
 [2006-04-07 18:20 UTC] hari_sayiri at rediffmail dot com
Yeah chregu, this way it works but when i get the string from some other program though the program send the same string it gives me the error message .....
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 16 11:01:31 2024 UTC