Bluehost.com Web Hosting $6.95

trouble parsing an XML document

This is a discussion on trouble parsing an XML document within the PHP General forums, part of the PHP Programming Forums category; Hello, I'm trying to parse a XML doc, but the doc has some tags like: <REG-ORIG> ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-14-2003
Alfredo
 
Posts: n/a
Default trouble parsing an XML document

Hello,
I'm trying to parse a XML doc, but the doc has some tags like:
<REG-ORIG>

so when I try to initialize variables:

class Documenti {
var $FILE; //nomefile
var $NUMERO; //numerodiserie
var ${'REG-ORIG'}; // here is the broblem
function Documenti($aa) {
foreach ($aa as $k=>$v)
$this->$k = $aa[$k];
}

i have an error:
Parse error: parse error, unexpected '$', expecting T_VARIABLE...

I tryed changing the $ position:
var {$'REG-ORIG'}; // here is the broblem

does not change anything:
Parse error: parse error, unexpected '{', expecting T_VARIABLE...

thanks for any suggestion,
Alfredo (Italy)
Reply With Quote
  #2 (permalink)  
Old 12-14-2003
Raditha Dissanayake
 
Posts: n/a
Default Re: [PHP] trouble parsing an XML document

doesn't look like a xml parser problem. I haven't tried your code but i
think the error is $this->$k

alfredo wrote:

> Hello,
> I'm trying to parse a XML doc, but the doc has some tags like:
> <REG-ORIG>
>
> so when I try to initialize variables:
>
> class Documenti {
> var $FILE; //nomefile
> var $NUMERO; //numerodiserie
> var ${'REG-ORIG'}; // here is the broblem
> function Documenti($aa) {
> foreach ($aa as $k=>$v)
> $this->$k = $aa[$k];
> }
>
> i have an error:
> Parse error: parse error, unexpected '$', expecting T_VARIABLE...
>
> I tryed changing the $ position:
> var {$'REG-ORIG'}; // here is the broblem
>
> does not change anything:
> Parse error: parse error, unexpected '{', expecting T_VARIABLE...
>
> thanks for any suggestion,
> Alfredo (Italy)
>



--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
Reply With Quote
  #3 (permalink)  
Old 12-15-2003
Sven
 
Posts: n/a
Default Re: [PHP] trouble parsing an XML document

hi,

Raditha Dissanayake schrieb:

> doesn't look like a xml parser problem. I haven't tried your code but i
> think the error is $this->$k


no, why not a variable method depending on $k?

> alfredo wrote:
>
>> Hello,
>> I'm trying to parse a XML doc, but the doc has some tags like:
>> <REG-ORIG>
>>
>> so when I try to initialize variables:
>>
>> class Documenti {
>> var $FILE; //nomefile
>> var $NUMERO; //numerodiserie
>> var ${'REG-ORIG'}; // here is the broblem


take a look at http://www.php.net/manual/language.variables.php:
"A valid variable name starts with a letter or underscore, followed by
any number of letters, numbers, or underscores."
so, a minus isn't allowed in varnames!
hth SVEN

>> function Documenti($aa) {
>> foreach ($aa as $k=>$v)
>> $this->$k = $aa[$k];
>> }
>>
>> i have an error:
>> Parse error: parse error, unexpected '$', expecting T_VARIABLE...
>>
>> I tryed changing the $ position:
>> var {$'REG-ORIG'}; // here is the broblem
>>
>> does not change anything:
>> Parse error: parse error, unexpected '{', expecting T_VARIABLE...
>>
>> thanks for any suggestion,
>> Alfredo (Italy)
>>

>
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:56 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0