linq-to-xml

How to read stackoverflow rss feed using linq to xml

烈酒焚心 提交于 2019-12-12 02:48:32
问题 I am trying read rss feed of stack overflow using Linq to xml. I am unable to get the entry nodes, as it is returning empty list. This I've tried so far, can any one point out what i am doing wrong here? Here I am binding to the grid view: private void StackoverflowFeedList() { grdFeedView.DataSource = StackoverflowUtils.GetStackOverflowFeeds(); grdFeedView.DataBind(); } This is the method which will get all feeds: public static IEnumerable<StackOverflowFeedItems> GetStackOverflowFeeds () {

getting values out of XML using LINQ to XML

十年热恋 提交于 2019-12-12 02:24:01
问题 I hate to be the village idiot, but I have no clue how Linq to XML works. I know it is supposed to be like writing a SQL query, but I just can't wrap my head around it. I am trying to get data out of an XML string. I don't want to use XMLDocuments and XPath to do this. I could do that, I did do that, I am trying to make my application a bit more snazzy. The XML that I have is a little bit onerous, but I was able to use Xpath to parse it. Linq to XML is supposed to be so much easier. From the

Pasing nested array using LINQ to XML

被刻印的时光 ゝ 提交于 2019-12-12 01:37:33
问题 I have xml like the below: <array> <dict> <key>Topic</key> <string>ABC</string> <key>Items</key> <array> <dict> <key>Header</key> <string>Data One</string> <key>Content</key> <array> <string>This is how we parse the data.</string> <string>This is how we parse the data.</string> </array> </dict> <dict> <key>Header</key> <string>Data Two</string> <key>Content</key> <array> <string>I am now able to parse the data</string> <string>I am now able to parse the data</string> </array> </dict> </array>

How to AspxMenu fill from xml file

狂风中的少年 提交于 2019-12-12 01:30:04
问题 On my page I have two AspxMenu.Click on Master Menu correspondent value will show on Child menu XML syntax: <Demo> <ClientCompanyId CompanyId="1"> <MyMenu> <module Text="Basic Settings" ModID="Mod1" ModuleID="1" MenuType="0" Perm="False"> <menu Text="Forms" MID="1-1" ParentID="Mod1" MenuDescription="Mod" ModuleID="1" MenuType="0" Perm="False"> <Leaf Text="LookUp" MID="1-3" ParentID="1" MenuDescription="" ModuleID="1" MenuType="0" Perm="False" LeafNode="true" TargetUrl="" ModuleMenuID="1-3"> <

How to get the value of a specific nested XML element using LINQ to XML

安稳与你 提交于 2019-12-12 01:06:18
问题 I have the XML like this <Root> <NodeA> <NodeA1> <NodeA11> <SameNameNode> <SameNameNodeChild1>Value 1</SameNameNodeChild1> <SameNameNodeChild2>Value 2</SameNameNodeChild2> </SameNameNode> </NodeA11> </NodeA1> </NodeA> <NodeB> <SameNameNode> <SameNameNodeChild1>Value 3</SameNameNodeChild1> <SameNameNodeChild2>Value 4</SameNameNodeChild2> </SameNameNode> </NodeB> <NodeC> <NodeC1> <SameNameNode> <SameNameNodeChild1>Value 5</SameNameNodeChild1> <SameNameNodeChild2>Value 6</SameNameNodeChild2> <

C# - Linq to XML - Exclude elements from query

我是研究僧i 提交于 2019-12-12 00:48:21
问题 I have this XML file: <MyXml> <MandatoryElement1>value</MandatoryElement1> <MandatoryElement2>value</MandatoryElement2> <MandatoryElement3>value</MandatoryElement3> <CustomElement1>value</CustomElement1> <CustomElement2>value</CustomElement2> <MyXml> All 3 elements that are called 'MandatoryElementX' will always appear in the file. The elements called 'CustomElementX' are unknown. These can be added or removed freely by a user and have any name. What I need is to fetch all the elements that

How to get an specific node in xml with namespaces?

强颜欢笑 提交于 2019-12-12 00:39:28
问题 I'm dealing to access an specific node from a XML Document. I realized that this one as a base namespace. Here is the example. I'm interested to get the value of the node d:MediaUrl from all descendents node (entry). And I haven't accomplished that. When I debug the variable iterator 'i', I can see that the XML includes the default namespace again, something like: <entry xmlns="http://schemas.microsoft.com.ado/..." And also I have to include the another namespace called 'd'. What can I do to

Appending new XElement adds an entire XML to existing xml in stream

人盡茶涼 提交于 2019-12-12 00:36:08
问题 I have an existing XML stored in the InternalFielStorage as.. <?xml version="1.0" encoding="utf-8" standalone="yes"?> <Root> <Books> <Author name="Sam" /> </Books> </Root> I am trying to append a "title" node under the "Author" node but the when saved, I am seeing a completly new xml added to the existing xml as.. <?xml version="1.0" encoding="utf-8" standalone="yes"?> <Root> <Books> <Author name="Sam" /> </Books> </Root> <?xml version="1.0" encoding="utf-8" standalone="yes"?> <Root> <Books>

Flatten XML structure by element with linq to xml

送分小仙女□ 提交于 2019-12-11 23:39:06
问题 I recently created a post about flattening an XML structure so every element and it's values were turned into attributes on the root element. Got some great answer and got it working. However, sad thing is that by flattening, the client meant to flatten the elements and not make them into attributes :-/ What I have is this: <members> <member xmlns="mynamespace" id="1" status="1"> <sensitiveData> <notes/> <url>someurl</url> <altUrl/> <date1>somedate</date1> <date2>someotherdate</date2>

Using LINQ to XML to match deeper descendant elements?

为君一笑 提交于 2019-12-11 23:19:41
问题 Suppose I have the following XML file: <?xml version="1.0" encoding="UTF-8"?> <response> <project> <ixGroup>105</ixGroup> <sGroup>Place Group</sGroup> </project> <project> ... And I use the following code to extract the distinct <ixGroup> and <sGroup> text values from it: XDocument doc = XDocument.Load(@"C:\temp\xmlParse2.xml"); var projects = (from project in doc.Descendants("project") select new { id = project.Element("ixGroup").Value, name = project.Element("sGroup").Value }).Distinct();