attributes
要素の属性/値を返します。
attributes()
関数は、XML要素の属性と値を返します。
返回xml <body>元素的属性和值:
<?php $ note = <<< xml <ノート> <to> george </to> <from> john </from> <見出し>リマインダー</heading> <body date = "2014-01-01" type = "private">今週末私を忘れないでください!</body> </note> XML ; $ xml = simplexml_load_string ( $ note ) ; foreach ( $ xml- > body [ 0 ] - > attributes ( ) as $ a => $ b ) { echo $ a 、 '= "' 、 $ b 、 " <br> " ; } ?>
运行实例
SimplexmLelement :: astibutes ( ns 、 prefix )
パラメーター | 説明する |
---|---|
ns | オプション。取得した属性の名前空間を指定します。 |
プレフィックス | オプション。 NSがプレフィックスである場合、trueが指定されています。 NSがURIの場合、FALSEが指定されています。デフォルトはfalseです。 |