note 113164 added to simplexmlelement.attributes
| From: | webfelipemaia at gmail dot com | Date: | Sat, 07 Sep 2013 05:11:26 +0000 |
| Subject: | note 113164 added to simplexmlelement.attributes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196189@lists.php.net to get a copy of this message | ||
Use attributes to display when it meets certain condition defined attribute / value in xml tags.
Use atributos para exibir quando atende determinada condição definida atributo / valor em tags
XML.
Consider the following example:
Considere o seguinte exemplo:
(file.xml)
<?xml version="1.0" encoding="UTF-8"?>
<list>
<item type="Language">
<name>PHP</name>
<link>www.php.net</link>
</item>
<item type="Database">
<name>Java</name>
<link>www.oracle.com/br/technologies/java/â</link>
</item>
</list>
Checks if the attribute value equals "Language", if equal prints everything that is
related to "Language".
Verifica se o valor do atributo é igual a "Language", se for, imprime tudo o que for
relativo ao mesmo.
<?php
$xml = simplexml_load_file("file.xml");
foreach($xml->children() as $child) {
$role = $child->attributes();
foreach($child as $key => $value) {
if($role == "Language")
echo("[".$key ."] ".$value . "<br />");
}
}
?>
output:
saÃda:
[name] PHP
[link] www.php.net
----
Server IP: 69.147.83.199
Probable Submitter: 177.17.25.207
----
Manual Page -- http://php.net/manual/en/simplexmlelement.attributes.php
Edit -- https://master.php.net/note/edit/113164
Del: integrated -- https://master.php.net/note/delete/113164/integrated
Del: useless -- https://master.php.net/note/delete/113164/useless
Del: bad code -- https://master.php.net/note/delete/113164/bad+code
Del: spam -- https://master.php.net/note/delete/113164/spam
Del: non-english -- https://master.php.net/note/delete/113164/non-english
Del: in docs -- https://master.php.net/note/delete/113164/in+docs
Del: other reasons-- https://master.php.net/note/delete/113164
Reject -- https://master.php.net/note/reject/113164
Search -- https://master.php.net/manage/user-notes.php