⊗ppSpXmTA 24 of 83 menu

XML Tag Attributes in PHP

Now let the tag have attributes:

<root> <tag attr="val">text</tag> </root>

To get the attribute value, you need to access $xml->tag as an array:

<?php echo $xml->tag['attr']; // outputs 'val' ?>

However, if you simply output $xml->tag, you will get the tag text:

<?php echo $xml->tag; // outputs 'text' ?>

Given the following XML:

<root> <user age="23" salary="1000">john</user> </root>

Display the user's name, age, and salary.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline