PHP attributes() ອາງສານ

ການອະທິບາຍ ແລະ ການນໍາໃຊ້

attributes() ອາງສານຂອງ SimpleXML ອາງສານ.

ອາງສານຕາມການອະທິບາຍ ແລະ ຄວາມມູນຂອງ XML ອາງສານ.

ຂອບຂອງຖານ

class SimpleXMLElement
{
string attributes(ns,is_prefix)
}
ປະເພດ ການອະທິບາຍ
ns ທຽບເຄື່ອງ. ຄວາມຊື່ນຂອງຄອມພິວເຕີ້ທີ່ຖືກຊອກຫາ.
is_prefix ທຽບເຄື່ອງ. ຄົນທີ່ບໍ່ມີຄວາມສົມບູນຈະເປັນ false.

ຕົວຢ່າງ

XML ບັນຊີ:

<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body type="small" important="low">ບໍ່ອອກຫາການນັດພົບ!</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"