PHP attributes() ఫంక్షన్
నిర్వచనం మరియు వినియోగం
attributes() ఫంక్షన్ PHP SimpleXML ఎలిమెంట్ యొక్క అంతర్జాతీయ పేరులను పొందుతుంది.
ఈ ఫంక్షన్ ఒక XML టాగ్ లో నిర్వచించబడిన అంతర్జాతీయ పేరు మరియు విలువలను అందిస్తుంది.
సంతకం
class SimpleXMLElement { string attributes(ns,is_prefix) }
పారామీటర్స్ | వివరణ |
---|---|
ns | ఎంపికలు. సర్చ్ చేయబడుతున్న అంతర్జాతీయ పేరు అవకాశం. |
is_prefix | ఎంపికలు. డిఫాల్ట్ ఆయిస్ ఫాల్స్. |
ఉదాహరణ
XML ఫైల్:
<?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>George</to> <from>John</from> <heading>Reminder</heading> <body type="small" important="low">Don't forget the meeting!</body> </note>
PHP కోడ్:
<?php $xml = simplexml_load_file("test.xml"); foreach($xml->body[0]->attributes() as $a => $b) { echo $a,'="',$b,'"'; } ?>
అవుట్పుట్ ఉంది:
type="small" important="low"