試圖拉從交通局狀態供稿一些數據 -的Xpath不起作用
<LineStatus ID="6" StatusDetails="Minor delays between Acton Town and Heathrow/Uxbridge due to an earlier faulty train at Holborn. GOOD SERVICE on the rest of the line.">
<BranchDisruptions>
<BranchDisruption>
<StationTo ID="244" Name="Uxbridge"/>
<StationFrom ID="1" Name="Acton Town"/>
<Status ID="MD" CssClass="GoodService" Description="Minor Delays" IsActive="true">
<StatusType ID="1" Description="Line"/>
</Status>
</BranchDisruption>
<BranchDisruption>
<StationTo ID="284" Name="Heathrow Terminal 5"/>
<StationFrom ID="1" Name="Acton Town"/>
<Status ID="MD" CssClass="GoodService" Description="Minor Delays" IsActive="true">
<StatusType ID="1" Description="Line"/>
</Status>
</BranchDisruption>
</BranchDisruptions>
只需使用XPath = // @名工作摳出來的數據在我們的標牌軟件的名稱元素,但我不知道如果父節點在<BranchDisruption>
之下,節點將顯示出來。嘗試了很多組合沿線,
xpath=//@Name[not(ancestor::BranchDisruption)]
但沒有運氣。有沒有人有什麼建議?
父母下面沒有屬性爲'Name'的元素 – splash58
準確地寫出你想從示例中選擇的元素 – splash58
嗨splash58,抱歉,讀那個回來我遺漏了一些信息。你在哪裏有Name =「Uxbridge」,這對我很有用(代碼將'Uxbridge'拉出來,但如果它位於標籤下,我不希望它工作(頁面上的代碼更多 –