我有以下格式的XML的LINQ to XML查詢(基本)
"<root>"
"<page>"
"<title>text</title>"
"<text attrib1="1">some text</text>"
"<text attrib1="2">some text</text>"
"<text attrib1="3">some text</text>"
"<text attrib1="4">some text</text>"
"</page>"
"<page>"
"<title>text</title>"
"<text attrib1="1">some text</text>"
"<text attrib1="2">some text</text>"
"<text attrib1="3">some text</text>"
"<text attrib1="4">some text</text>"
"</page>"
"</root>"
忽略 「」
現在我想這樣
"<root>"
"<title>text</title>"
"<text attrib1="4">some text</text>"
"<title>text</title>"
"<text attrib1="4">some text</text>"
"</root>"
生成的XML能這樣在一個查詢中實現? 我嘗試用兩個查詢
var titleElms =
from t in allElements
select
new
{
Title = t.Element("title")
};
var textElms =
from t in allText
where (string)t.Attribute("attrib1").Value == "4"
select
t;
我不喜歡它的下面。那麼還有其他方法嗎?請幫助。
你能告訴你正在嘗試使用XML,而不是文字呢? – UpTheCreek 2009-12-08 10:44:07
嘿對不起你們即時通訊無法粘貼XML這裏的所有標籤兵刪除..:'( – Amit 2009-12-08 10:46:40
放在一個代碼塊,就像你用C#做 – UpTheCreek 2009-12-08 10:47:13