attributes
返回元素的屬性/值。
attributes()
函數返回XML 元素的屬性和值。
返回xml <body>元素的屬性和值::
<? php $ note = <<< xml <note> <to>喬治</to> <來自> John </from> <Theed>提醒</heading> <hody date =“ 2014-01-01” type =“ private”>不要忘記我這個週末! </body> </note> xml ; $ xml = simplexml_load_string ( $ note ) ; foreach ( $ xml- > body [ 0 ] - >屬性( )為$ a => $ b ) { echo $ a , '=“' , $ b , ” <br>“ ; } ? >
運行實例
SimpleXMLElement :: attributes ( ns , prefix )
參數 | 描述 |
---|---|
ns | 可選。指定檢索屬性的命名空間。 |
prefix | 可選。如果ns是前綴,則指定TRUE;如果ns是URI,則指定FALSE。默認為FALSE。 |