假設我有這個XML文件。PHP閱讀XML與Where子句
<book>
<id>1</id>
<title>Harry Potter - bla bla bla</title>
<author>J.K Rowling</author>
</book>
<book>
<id>2</id>
<title>Other book</title>
<author>A Name</author>
</book>
有沒有一種方法,我可以通過PHP讀取並獲得#2 ID,或者我必須使用IF? 像jQuery選擇 ':公式(2)',或MySQL 'WHERE id
= 2'
什麼actualy,我不知道這樣做,搜索並沒有取得成功。 – BernaMariano
xpath:// book [id =「2」] – Gordon
旁註:在子元素中使用id可能不是最好的主意。 ''(+也許將'id'定義爲類型(ID)的屬性)將是更可取的。 –
VolkerK