linq-to-xml

One to Many Linq to XML query

Hi, I have an XML string that looks like this: <Attributes> <ProductAttribute id="1"> <ProductAttributeValue> <Value>a</Value> </ProductAttributeValue> </ProductAttribute> <ProductAttribute id="2"> <ProductAttributeValue> <Value>a</Value> </ProductAttributeValue> ...

[WPF/XAML/C#] Why databinding TwoWay don't work on the text property of a combobx in .net 4.0 ?

Hello, Why databinding TwoWay don't work on the text property of a combobx in .net 4.0 (it's working in .net 3.5) ? My code : I have an xml file like this : <xml> <combobox option="" obs="tralala"> <option value="here" /> <option value="there" /> </combobox> <combobox option="blue" obs=""> <option value="one" /> ...

Is it possible to do reflection in a select of LINQ2XML?

New question about the previous question Previous question was: I have to populate a few objects that contains 30-50 property from a few linq to xml results is there a way to populate these object without having to manually write every specific prop=value for every property? a kind of (from xml in myXml select xml).ToLis...

XElement.Elements(XName name) doesn't return a name that exists in XElement.Elements()

As you can see, the schema.Elements returns three elements one of whom is an EntityContainer element. But when I try to search thru the Elements overload specifying the "EntityContainer" (schema.<EntityContainer>) it doesn't retrieve anything. ...

Basic rules engine architecture

We are currently developing a project in .NET that involves analyzing XML documents against a set of user defined rules. Here is an example: <Person> <Name>Bob</Name> <Cars> <Car Type="SUV" Color="Black"/> <Car Type="Sports" Color="Red"/> <Cars/> </Person> EG rules: if person's name = "Bob" and has 2 cars then ......

xml to data structure

I have an xml file that looks like this <step> <id>3</id> <backid>1</backid> <question>Are you having a good day</question> <yesid>4</yesid> <noid>5</noid> </step> It's set up to be an application that asks the user yes and no questions to assist in guiding the user through a complicated business process. T...

Strange characters returned when using Linq to XML

Hi, I'm trying to write some C# code to read data from an XML file. I thought I'd try out Linq to XML to do this. However, the values I'm pulling out are surrounded by characters like "\n\t\t\t". Can anyone explain why I'm getting these characters, and how I can remove them? Thanks. ...

How to use XPath with XElement or LINQ?

Consider the following XML: <response> <status_code>200</status_code> <status_txt>OK</status_txt> <data> <url>http://bit.ly/b47LVi&lt;/url&gt; <hash>b47LVi</hash> <global_hash>9EJa3m</global_hash> <long_url>http://www.tumblr.com/docs/en/api#api_write&lt;/long_url&gt; <new_hash>0</new_hash> </data> </response>...

how to get childnodes if i pass the parent node id to the xml in silverlight?

I have a xml in the below format and need to get the id and name of all the SubEntity when I pass the ParentEntityId. This needs to be done in silverlight. <Treeview> <ParentEntity ParentEntityId="1" ParentEntityName="P1"> <Facility FacilityId="F1" FacilityName="F1"> <Category CategoryId="C1" CategoryName="C1"/> ...

How do I refer itself's value in dynamic linq to XML?

Hi, I'm using Scott Gu's dynamic linq library for Linq to XMl. The problem is I don't know how to refer an element itself value inside of the dynamic query. What I want to do is as follows: var doc = XDocument.Load("test.xml"); var ret = doc.Descendants("Row").Where(x => x.Element("ID").Value == "2").ToList(); I want to replace the ...

Do I need to dispose/close XDocument.Load(string)?

I can't find any info about whether or not I should dispose/close this object after using it... Here is the msdn link: http://msdn.microsoft.com/en-us/library/bb343181.aspx ...

Add Stylesheet reference to XML Document in Linq?

I create an XML Doc and wanted have a reference to the XSLT file. //<?xml-stylesheet type="text/xsl" href="OBReport.xslt"?> to this XML generation: XElement xml = new XElement("ReportedOn", from dl in EL.DocumentLog.ToList() join o in EL.Organization on dl.OrganizationID eq...

LINQ to XML generates \r\n between tags?

Hello, I am generating a XElement having this structure: <TestNames>\r\n <Test>YA</Test>\r\n <Test>YO</Test>\r\n </TestNames> How do I get rid of the whitespaces and \r\n in a non-hack way :) Update: XElement testsXmlDocument= new XElement("TestNames"); foreach (string test in selectedTests) testsXmlDocumen...

C# Linq XML pull out nodes from document

Hi I’m trying to use Linq XML to select a number of nodes and the children but getting terrible confused! In the example XML below I need to pull out all the <MostWanted> and all the Wanted with their child nodes but without the other nodes in between the Mostwanted and Wanted nodes. This because each MostWanted can be followed by any ...

trouble parsing deeply nested attributes using LINQ to XML

I have been trying to parse this xml in c# <schema uri=http://blah.com/schema > <itemGroups> <itemGroup description="itemGroup1 label="itemGroup1"> <items> <item description="The best" itemId="1" label="Nutella"/> <item description="The worst" itemId="2" label="Vegemite"/> </items> </itemGroup...

LINQ to XML: What is the most effective way to move nodes up and down

I need to move sibling nodes before and after certain nodes. Here is the code im working with <tabs> <tab> <name>Overview</name> </tab> <tab> <name>Testing</name> </tab> <tab> <name>Performance</name> </tab> <tab> <name>Braking</name> </tab> </tabs> I woul...

Using LINQ to XML to traverse an HTML table

So, I can easily use LINQ to XML to traverse a properly set-up XML document. But I'm having some issues figuring out how to apply it to an HTML table. Here is the setup: <table class='inner' width='100%'> <tr> <th> Area </th> <th> Date </th> <th> ID ...

What is the difference between Linq to XML Descendants and Elements

I have came across both these keywords in the VS Intellisense. I tried to googling the difference between them and did not get a clear answer. Which one of these have the best performce with small to medium XML files. Thanks ...

Why is this Linq to XML query not working

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Linq; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { XDocument xDocument = new XDocument( new XElement("BookParticipants", new XElem...

Extracting data from CDATA using LINQ to XML

I have the following xml file and I am trying to use linq to xml to get the Elements which are residing inside the CDATA section. Any suggestions please. <?xml version = "1.0" encoding = "UTF-8"?> <result final = "true" transaction-id="84WO" xmlns="http://cp.com/rules/client"&gt; <client id = "CustName'> <quoteback> </client> <report fo...