Page 1 of 1

XML Attr's

Posted: Fri Aug 23, 2002 1:46 pm
by hob_goblin
Using this tutorial: http://www.phpbuilder.com/columns/justi ... hp3?page=3 , i am at the point where i know how to parse the xml file and print out the information formatted. i wanted to know how i could access the attributes in the xml and use them..

like if i had

<foo bar="green">foobar</foo>

i could make the html:

<font color="green">foobar</font>

i would somehow have to put it into $this->open_tag

Posted: Fri Aug 23, 2002 4:43 pm
by nielsene
Just to post a followup to an IM discussion on this

Example three at php.net/xml gives an example of playing with the attributes.

Posted: Fri Aug 23, 2002 6:52 pm
by volka

Code: Select all

&#1111;...]$this->open_tag = &#1111;...]
  "foo" => '<?php?>return("<font color="&#123;$attrs&#1111;''bar'']&#125;">");'
&#1111;...]
function startElement($parser, $name, $attrs)
&#123;
	if ($format= $this->open_tag&#1111;$name])
	&#123;
		if ("<?php?>" == substr($format, 0, 7))
		&#123;
			$format= eval(substr($format, 7));
			$this->html = $format;
		&#125;
		else
			$this->html .= $format;
	&#125;
&#125;&#1111;...]
should (hopefully) work