Re: [PHP-XML-DEV] php bug?

[email protected] (Rob Richards) Mon, 27 Sep 2010 07:29:55 -0400
Newsgroups php.xml.dev
Message-ID <[email protected]>
  On 9/27/10 4:06 AM, mcberta2 wrote:
> On 9/26/2010 6:34 PM, Adam Trachtenberg wrote:
>> On Sun, Sep 26, 2010 at 12:36 AM, mcberta2<[email protected]>  
>> wrote:
>>
>>> Hello everyone.
>>> The following is an extract of a routine returning error messages 
>>> from a
>>> xml file:
>>>
>>> function title($index)
>>> {
>>> $xml = simplexml_load_file("lingo.xml");
>>> return $xml->message[$index];
>>> }
>>>
>>> The problem is that if I call the routine with a value [ex. title(6)] I
>>> receive the message, whereas if I call the routine with a variable [ex.
>>> title($value) where $value=6] there is no way I can receive the 
>>> message.
>>>
>>> I tried in many different ways but it looks like it's a bug of 
>>> simple_xml.
>>>
>>
>> This isn't too helpful, but I'm 99.94% it's something in your code.
>>
>> Simplify your code until you find the shortest piece that works and 
>> then add
>> back lines until you find your error.
>>
>> -adam
>>
> Thank you for coming to help.
> That's what I did.
> The routine can't get shorter than that. I attach now the xml file 
> (shortest version). Just to be clear:
>
> <?xml version="1.0" encoding="utf-8"?>
> <messages>
> <message id="0">About us</message>
> <message id="1">Nothing has been ordered!</message>
> <message id="2">Continue shopping</message>
> <message id="3">Shopping cart</message>
> <message id="4">Contact us</message>
> <message id="5">News</message>
> <message id="6">Welcome</message>
> </messages>
>
> Am I referencing the nodes incorrectly?
> Thank you
> Andrea
>

How about the full script as you don't include how/what you are passing 
to the title function.

Rob