Jump to content

Php Getattribute Length


tinfanide

Recommended Posts

<?xml version="1.0" encoding="utf-8"?><root><name ######="M" age="15">Tin</name><name ######="F" age="13">Valerie</name><name ######="F" age="14">Valeriana</name><person name="Tin" ######="M" age="15" /></root>

Is there a way to get the attribute length in PHP?

<?php echo sizeof($xml->name); echo '<br />';echo sizeof($xml->name->attributes());  ?>

!!!The word '######' has just been renamed as #### by the siteBut that doesn't matter.!!! I've used simpleXML (confusing...unlike JScript) and tried to use sizeof();It works for tagNames and attributes within a tagName, But if I want to get the length of the attribute 'age' across the xml doc,is it possible?

Link to comment
Share on other sites

First ensure what$xml->name->attributes() is returning. it suppose to be return a simplexmlelement object which you need to iterate using loops when you will get the value you can then calculate the length of that using sizeof()http://in2.php.net/m....attributes.php if you are looking for similarity with js you may like to see http://in2.php.net/m...n/book.dom.php. which more versetile and more similar to DOM implmention of js

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...