2013-07-22 52 views
0
 <Parent> 
    <Children idontknowthis='thisisnotmyquestion'> 
    <x>1</x> 
    <x>2</x> 
    <x>3</x> 
    <x>4</x> 
    </Children> 
</Parent> 

示例下面我正在處理的.xml文件。我的腳本需要自行建立「身份證」(要清楚,我已經可以得到bk109)...使用PHP獲取XML屬性名稱(非值)

<book id="bk109"> 
     <author>Kress, Peter</author> 
     <title>Paradox Lost</title> 
     <genre>Science Fiction</genre> 
     <price>6.95</price> 
     <publish_date>2000-11-02</publish_date> 
     <description>After an inadvertant trip through a Heisenberg 
     Uncertainty Device, James Salway discovers the problems 
     of being quantum.</description> 
    </book> 

對於XML導入腳本的PHP其目的將導入許多不同的XML文件。我如何獲取屬性名稱? (即「id」)

+1

您能告訴我們用於獲取'bk109'的代碼嗎? – dusan

+0

我正在使用... foreach($ xml5 as $ header => $ book){ echo $ book-> attributes()。'
'; } –

+2

這個問題似乎是脫離主題,因爲它是關於閱讀手冊中的主題(或使用網站上的搜索)。 – hakre

回答