XML Attr's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

XML Attr's

Post 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
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
Post Reply