當前位置: 首頁> 函數類別大全> addAttribute

addAttribute

向SimpleXML 元素添加屬性。
名稱:addAttribute
分類:未分類
所屬語言:php
一句話介紹:向SimpleXML 元素添加屬性。

定義和用法

addAttribute()函數用於向SimpleXML 元素添加屬性。

實例

向根元素(<note>)和<body> 元素添加屬性:

 <?php
$note = <<< XML
<note>
<to>George</to>
<from>John</from>
<heading>Reminder</heading>
<body>Do not forget the meeting!</body>
</note>
XML ;

$xml = new SimpleXMLElement ( $note ) ;
// 向根元素添加屬性
$xml -> addAttribute ( "type" , "private" ) ;
// 向body 元素添加屬性
$xml -> body -> addAttribute ( "date" , "2014-01-01" ) ;

echo $xml -> asXML ( ) ;
?>

運行實例

文法

SimpleXMLElement :: addAttribute ( name , value , ns )
參數 描述
name 必需。指定要添加的屬性的名稱。
value 可選。指定屬性的值。
ns 可選。指定屬性的命名空間。
同類函數
  • 返回MySQL 協議版本。 get_proto_info

    get_proto_info

    返回MySQL協議版本。
  • 返回拋出異常的文件的完整路徑。 getFile

    getFile

    返回拋出異常的文件的完整路徑。
  • 返回文檔中聲明的命名空間。 getDocNamespaces

    getDocNamespaces

    返回文檔中聲明的命名空間。
  • 返回有關指定曆法的信息。 cal_info

    cal_info

    返回有關指定曆法的信息。
  • 清空libxml 錯誤緩衝。 libxml_clear_errors

    libxml_clear_errors

    清空libxml錯誤緩衝。
  • 從結果集中取得一行作為關聯數組,或數字數組,或二者兼有。 mysql_fetch_array

    mysql_fetch_array

    從結果集中取得一行作為關聯數組,或數字數
  • 返回ZIP 文件中的一個項目的實際文件尺寸。 zip_entry_filesize

    zip_entry_filesize

    返回ZIP文件中的一個項目的實際文件尺寸
  • 把文件上傳到服務器(non-blocking)。 ftp_nb_put

    ftp_nb_put

    把文件上傳到服務器(non-blocki
熱門文章