linq-to-xml

How can I iterate over a collection of objects returned by a LINQ-to-XML query?

I've got this XML: <BillingLog> <BillingItem> <date-and-time>2003-11-04</date-and-time> <application-name>Billing Service</application-name> <severity>Warning</severity> <process-id>123</process-id> <description>Timed out on a connection</description> <detail>Timed out after three retries.</detail> </BillingI...

Convert IEnumerable to EntitySet

Hey all, Hoping somebody can shed some light, and perhaps a possible solution to this issue I'm having... I have used LINQ to SQL to pull some data from a database into local entities. They are products from a shopping cart system. A product can contain a collection of KitGroups (which are stored in an EntitySet (System.Data.Linq.Ent...

Populate a TreeView with XML nodes using XElement with C#

I am using c#.net windows form application. I have a xml file. I need to populate all the nodes present in that file to a treeview. I need to do it using xelement. Please help me with the proper code. ...

How to grab location information in the XML using linq?

My xml looks like: <kml xmlns="http://earth.google.com/kml/2.0"&gt; <Response> <name>90210</name> <Status> <code>200</code> <request>geocode</request> </Status> <Placemark id="p1"> <address>Beverly Hills, CA 90210, USA</address> <AddressDetails Accuracy="5" xmlns="urn:oasis:name...

data is not getting ordered by date

Can't get list sorted by date. How to show data ordered by date? XDocument doc = XDocument.Load(Server.MapPath("file.xml")); IEnumerable<XElement> items = from item in doc.Descendants("item") orderby Convert.ToDateTime(item.Attribute("lastChanges").Value) descending ...

Linq To XML: Get Child XElement From Parent With Unknown Name

I currently have some XML similar to the following <First Node> <Second Node> <Third Node> <Fourth Node> 'Lots of Children in here </Fourth Node> </Third Node> </Second Node> </First Node> The issue is I know the exact names of the First, Second and Fourth Nodes. However t...

XDocument.Parse fails due to resolution error, how to disable resolution

I am trying to parse the contents of http://feeds.feedburner.com/riabiz using XDocument.Parse(string) (because it gets cached in a DB.) However, it keeps failing with the below stack trace when it tries to resolve some URIs in that XML. I don't care about validation or any of that XML nonsense, I just want the structure parsed. How can...

Excel XML Newline in Cell

I am using LINQ to XML to create an Excel XML file. I want to include newlines within the cells. Excel uses the &#10; literal to represent a new line. If I try to add this using an XText: XText newlineElement = new XText( "Foo&#10;Bar" ); I get: Foo&amp;#10;Bar Which shows up in Excel as: Foo&#10;Bar Is there a way to write &#10 t...

Get data from XDocument

So here's my XML file: <book> <title>Book Title</title> <author>Book Author</author> <pubDates> <date format="standard">1991-01-15</date> <date format="friendly">January 1991</date> </pubDates> </book> I'm loading the data into an XDocument, then retrieving it from the XDocument and adding it into a B...

LinqToXML why does my object go out of scope? Also should I be doing a group by?

Hello All, I have an IEnumerable<someClass>. I need to transform it into XML. There is a property called 'ZoneId'. I need to write some XML based on this property, then I need some decendent elements that provide data relevant to the ZoneId. I know I need some type of grouping. Here's what I have attempted thus far without much success. ...

How to bind a specific attribute from an xml using LINQ?

Hi i have a n xml like this: <Profile> <Interviewer id="111"> <Questions> <Question qid="1" Catid="1" CatagoryName="General"> <Video url="http://10.1.8.45/BIGWeb/videofiles/user1/I1C1Vid1.mp4" /> <Quest text="Tell me about yourself by intone ?" /> <videofile text="I1C1Vid1.mp4" /> </Question> ...

Why am I getting the extra xmlns="" using LINQ to XML?

Hello all, I'm using LINQ to XML to generate a piece of XML. Everything works great except I'm throwing in some empty namespace declarations somehow. Does anyone out there know what I'm doing incorrectly? Here is my code private string SerializeInventory(IEnumerable<InventoryInformation> inventory) { var zones = inventor...

linq-to-xml and carriage returns

What is the best what to handle carriage returns in xml formatting with xml? <myxml> <mydata> </mydata> </myxml> <myxml><mydata></mydata></myxml> ...

Parsing a string in c#

Hi, Suppose there is an xml file like below: <Instances> <Bits = "16" XCoord = "64" YCoord = "64" ZCoord = "64" FileType="jpeg" Location="C:\Series1\Image1.jpg" ImageNumber = "1"/> <Bits = "16" XCoord = "64" YCoord = "64" ZCoord = "64" FileType="jpeg" Location="C:\Series1\Image2.jpg" ImageNumber = "2"/> <Bits = "16" XCoord = "64"...

child objects in linq

I checked before I posted but couldn't find a solution. I'm new to linq and it is draining my brain to understand it. I have an xml and want to use linq to fill object that has a child object. the xml and my linq is below. My issue is on this line TaskItems = t.Elements("taskdetail").ToList<TaskItem>() //this line doesn't work how do...

Linq: read node innertext

i have a xml document like this: <ns:a xmlns:ns="http://NS1"&gt; <ns:b> <c xmlns="http://differentNS"&gt; c_text </c> <x xmlns="http://differentNS"&gt; Wanted </x> <d xmlns="http://differentNS"&gt; d_text </d> </ns:b> </ns:a> Now i want to use linq to read the element's "x" inner text. ...

How do I construct a more complex single LINQ to XML query?

I'm a LINQ newbie, so the following might turn out to be very simple and obvious once it's answered, but I have to admit that the question is kicking my arse. Given this XML: <measuresystems> <measuresystem name="SI" attitude="proud"> <dimension name="mass" dim="M" degree="1"> <unit name="kilogram" symbol="kg"> <fac...

Is it possible to create the following XML using Xdocument and append the relevant protion in subsequent go(C#3.0)

<?xml version='1.0' encoding='UTF-8'?> <StockMarket> <StockDate Day = "02" Month="06" Year="2010"> <Stock> <Symbol>ABC</Symbol> <Amount>110.45</Amount> </Stock> <Stock> <Symbol>XYZ</Symbol> <Amount>366.25</Amount> ...

Linq to xml : can't load all elements

hello i'm trying to load some elements from a xml file. but it XDocument.Load seems not treating xml file properly in this case, the method returns the content of the xml file as one node. here is my xml content: <processes> <process>winamp</process> <process>Acrobat</process> <process>WinRAR</process> </processes> and the code ...

How set timeout on XDocument.Load(string uri)?

Is there a way to set a timeout on System.Linq.Xml.XDocument.Load(string uri)? Or should I use the technique described in http://stackoverflow.com/questions/299198/implement-c-generic-timeout? ...