xelement

    1熱度

    1回答

    需要 XAttribute newatt = new XAttribute("TAG", value); 添加到XElement elem,但elem可能已經包含名爲"TAG"屬性,所以elem.Add(newatt);會給錯誤。我目前使用的解決方法是首先要檢查: if (elem.Attribute("TAG") != null) // check if attribute exists

    0熱度

    3回答

    我正在獲取.resx文件中多個元素的值。在一些data元素<comment>子元素不存在,所以當我運行以下時,我會得到一個NullReferenceException。 foreach (var node in XDocument.Load(filePath).DescendantNodes()) { var element = node as XElement; if (

    0熱度

    1回答

    我有IEnumerable<XElement> theTestCaseNodes它具有以下一種XElements <testcase> <Main> <test_step type ="action"> <Name>Goto</Name> <description>xxxxxxxxx</description> </test_step

    0熱度

    1回答

    將JavaScript放入C#中的XElement對象中的正確方法是什麼? 目前,我有以下幾點: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; names

    -1熱度

    2回答

    已更新 - 我試圖用C#將很多文本文件(最多3K文件)轉換爲XML文件。 我想遵循兩個步驟: 1)使用特定的分隔符「:」獲取一些數據。 2)使用* .txt文件的相同名稱在另一個文件夾中創建* .xml文件。 我花了很多時間從文本文件中使用LINQ獲取數據信息,並且所有數據都是正確的。我被困在如何發送這些數據到XML文件並保存。 這是我第一次使用文本文件和XML,任何幫助將非常感激。 下面的代碼:

    1熱度

    1回答

    如何選擇多個XML標記爲XElement,基於相同屬性進行過濾。 我有下面的代碼,我想是有行動選擇標記=真 <root> <first action="true"> <path>E:\Myfolder</path> </first> <second> <path>C:\Users\</path> </second> <third

    1熱度

    2回答

    這是我第一次使用XML文件,我可以使用一些幫助。我對C#也很新。我創建了一個包含基於主題的不同單詞集的XML文件。我想要做的是僅加載來自特定標籤的所有單詞。但是,我沒有收到錯誤,它只是跳過應該將其添加到列表框中的代碼。下面是我的XML文件的樣本: <?xml version="1.0"?> <theme> <fantasy> <word> <nn>wiz

    -1熱度

    2回答

    private XElement AuthorSeparate(List<string> authorName) { string surName = string.Empty; string initalName = string.Empty; string givenName = string.Empty; int j = 1;

    0熱度

    1回答

    我使用下面的程序來枚舉xml輸入中的元素。當到達最後一個元素時 x.MoveNext() 返回false,這部分是清楚的。我的問題是: 爲什麼它繼續打印<c>即使列表耗盡 爲什麼x.Current永遠等於空?這就是我所期待的,因爲XElement是引用類型 static void Main(string[] args) { var x = GetXml(); while (t

    0熱度

    2回答

    我從C#控制檯的許多源中讀取多個進料,和我有這個代碼,我加載XML來源: XmlDocument doc = new XmlDocument(); doc.Load(sourceURLX); XElement xdoc = XElement.Load(sourceURLX); 如何獲得外殼網址並顯示爲變量?