Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML attributes 1

Status
Not open for further replies.

wangbar

Programmer
Jul 23, 2001
1,906
GB
I can find plenty of information about parsing the separate nodes in an XML file using Expat and have got some code running successfully but can't find any hints on how to parse the attributes of a particular node.

I know that attributes are passed as the third parameter into the "opening tag" function but can't get anything meaningful out of them.

Any tips? Slainte

 
What do you use to parse the XML?

I use a class i got from the web to parse the XML files. I don't have it right now, but reading the manual, i found the function xml_parse_into_struct. Doesn't it helps you? Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
I'm using the built in parser set up using "xml_parser_create" then I'm using three functions: one triggered on every opening tag, one on the closing tag and one to read the content between them.

This all works great for accessing and parsing the individual nodes but I'll try your suggestion and see how it goes for picking up attributes... Slainte

 
sometime ago i was doing some tests and i could reach something like this:

$xml=implode("",file("share.xml"));
$dom=xmldoc($xml);
$root=domxml_root($dom);
$child=domxml_children($root);
while(list(,$value)=each($child)){
if (get_class($value)==&quot;DomElement&quot;) echo domxml_get_attribute($value,&quot;cod&quot;).&quot;-&quot;.$value->get_content().&quot;<br>&quot;;
}

This way i was able to get all attributes.

Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top