Why does simpleXML give me nested objects for blank tags?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Repost as I got zero replies. Does anyone know why this is? Seems like a bug
to me, or at least should be documented as such whacky behavior. Are there
any solutions to this or work-arounds?

-----Original Message-----
From: Daevid Vincent [mailto:daevid@xxxxxxxxxx] 
Sent: Thursday, June 18, 2009 6:04 PM

I'm trying to use
http://us2.php.net/manual/en/function.simplexml-load-string.php
 
$xml_url =
file_get_contents('http://myserver/cgi-bin/foo.cgi?request=c901c906e4d06a0')
;
try
{
 $xml = simplexml_load_string($xml_url, 'SimpleXMLElement', 
					LIBXML_NOBLANKS & LIBXML_COMPACT &
LIBXML_NOEMPTYTAG);
 print_r( $xml);
}
catch (Exception $e)
{
 echo "bad xml";
}
 
If I have this XML file (note the tags I marked with --> below):
 
<issue>
	<crstatus>i_field_submitted</crstatus>
	<problem_number>151827</problem_number>
	<problem_synopsis_field>title</problem_synopsis_field>
	<problem_description_field>description2</problem_description_field>
	<fi_priority>High</fi_priority>
-->	<assignee/>
	<create_time>5/12/2009 22:53:10</create_time>
-->	<fi_notes_oem/>
	<fi_sw_part_name>sw_part_name</fi_sw_part_name>
	<fi_general_reference>general_reference</fi_general_reference>
	<fi_sw_part_number>sw_part_num</fi_sw_part_number>
	<fi_customer_ecd_date>1244703600</fi_customer_ecd_date>
	<fi_sw_part_version>sw_part_version</fi_sw_part_version>
	<fi_required_date>1243839600</fi_required_date>
-->	<ac_type/>
</issue>
 
Why does it give me sub-objects and not just empty strings for tags that
have no values as I'd expect??!
I tried all those options above and none of them make a difference.

SimpleXMLElement Object
(
    [crstatus] => i_field_submitted
    [problem_number] => 151827
    [problem_synopsis_field] => title
    [problem_description_field] => description2
    [fi_priority] => High
--> [assignee] => SimpleXMLElement Object
        (

        )

--> [fi_notes_oem] => SimpleXMLElement Object
        (

        )

    [fi_sw_part_name] => sw_part_name
    [fi_general_reference] => general_reference
    [fi_sw_part_number] => sw_part_num
    [fi_customer_ecd_date] => 1244703600
    [fi_sw_part_version] => sw_part_version
    [fi_required_date] => 1243839600
--> [ac_type] => SimpleXMLElement Object
        (

        )

)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux