Re: trouble parsing an XML document

From: Date: Mon, 15 Dec 2003 14:17:21 +0000
Subject: Re: trouble parsing an XML document
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-172734@lists.php.net to get a copy of this message
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)


« previous php.general (#172734) next »