linq-to-xml

LINQ to XML Databinding - not updating my ListBox

Hi, I'm using Linq to XML with databinding, and it is partly working in that my textbox fields correctly display the selected item from my ListBox. The Listbox is databound to a List<> which is loaded from an XML file at initialisation time, and the textbox's are also databound to the same List<>. I've also written a function that clea...

How to get a List<XElement> from this XML?

I have a block of XML similar to the following: <factsheet> <bilcontents > <config name="1" /> </bilcontents> <singlefactsheet includeInBook="true"> <config name="7" /> <fund id="630" /> </singlefactsheet> <doubleFactsheet includeInBook="true"> <config name="8" /> <fund id="623" /> <fund id="624" /> </doubleFactsheet> <tr...

Problem in ListBox ItemTemplate binding using XML as itemssource

I'm having a bit o' trouble... Here is my "mappings.xml" file... <?xml version="1.0" encoding="utf-8"?> <mappings> <mapping QID="info1"> <empty></empty> </mapping> <mapping QID="info2"> <empty></empty> </mapping> </mappings> My method that loads the XML and sets it as the ItemsSource for the listbox: (Note: I didn't ...

How to bind XML with namespace to WPF DataGrid ?

Hello again, I have a use-case where I need to bind data from an XML file to a WPF DataGrid. I prepared this example to demonstrate what I'll be doing in my final code. This is Books.xml: <?xml version="1.0" encoding="utf-8" ?> <library> <books> <book id="1" name="The First Book" author="First Author"> First Book Content ...

C# linq-to-xml, Getting a list with nodes?

Hi! This is the test xml that i am using: <categories> <category id="1" name="Test1"> <category id="2" name="Test2"> <misc id="1"></misc> </category> </category> <category id="3" name="Test3"> <misc id="2"></misc> </category> Now i want to bind that to an ASPX treeview, i want only the elements that have...

Handling nested XML

Hi - looking for best practice in converting a parent-child relationship using Linq to XML In this case i have a Domain class which contains a Group[] What I want to do is iterate over the Groups[] in d (domains) and create the XElements in one hit. XElement _customers = new XElement("Domains", ...

Upgrading XML Schema programmatically

Hi all. I'm in the process of having to re-write a project due to the platform vendor needing the storage mechanism be in an XElement object instead of storing in data tables that I create in their database. It's becoming painful, and I need some insight. I can morph my object graph to/from Xml using the XmlSerializer and read/write t...

LINQ to XML and RIA Services?

What is the difference between the two? Are they supposed to perform one and the same function - data binding? Or are they "apples and oranges" in comparison? ...

Linq To Xml datasource for grid view is not working. The grid show no rows

Hi All, I'm getting some Xml back from a service. I would like it to be the datasource of a grid view on my aspx page. Here is a sample of the Xml <?xml version="1.0" encoding="utf-16" ?> <ArrayOfTripTollCompleteDC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <TripTollC...

LINQ to XML, joining 2 XML files

i have got 2 XML files to join and having a lot of trouble joining them. Im trying to use LINQ to XML to do it, but i havent quite figured out how i can make them join, or if its possible. here is what they look like: <?xml version="1.0" encoding="utf-8"?> <routes> <route> <id>9</id> <street>3</street> <street>12</street...

XElement.GetSchemaInfo() is returning null, Why?

Hello all, I'm trying to validate an XDocument with a compiled schema that I have (which works) but when I try to access PSVI for the root XElement it returns null. I need this so I can validate child XElements. Here is a sample code of what I'm trying to do: XDocument xmlDoc = XDocument.Load(xmlFilePath); XElement root = _xmlDoc.El...

Getting wrong information when scraping XML with Linq.

Image I have this XML: <ipb> <profile> <id>335389</id> <name>stapia.gutierrez</name> <rating>0</rating> </profile> </ipb> I'm trying to get ID, Name and Rating. Any guidance? Here's what I have and what I receive: public User FindInformation() { string xml = new WebClient().DownloadString(String.For...

Parsing an Atom feed via LINQ to XML

I wrote a code snippet to extract elementary information from an Atom feed (e.g. a SO feed) using a LINQ to XML query. I'd like to know if there are be cases when this code could fail or if there are more elegant ways. Thanks for the support. var url = @"http://stackoverflow.com/feeds"; XDocument rss = XDocument.Load(url); var q = f...

How do I neatly remove nodes from an XDocument using LINQ and Lamda?

What's the most elegant way of going from this: <?xml version="1.0" encoding="UTF-8"?> <foo> <bar baz="wii" date="2009-01-01"> <baz value="0" /> <baz value="1" /> </bar> <bar baz="wii" date="2009-01-02"> <baz value="0" /> <baz value="1" /> </bar> <bar baz="xbox" date="2009-01-01"> <baz value="0" /> <baz value="1"...

add parent to xml linq

Hello, Is it possible to add parent to xml elements ? <node1> <node2></node2> <node2></node2> </node1> and I would like to have : <node1> <node3> <node2></node2> <node2></node2> </node3> </node1> so added node3 as parent for node 2 elements in this part ...

how to fetch values from special attribute names with LINQ and XML

XML is like this: <element customer-name="blabla" customer-identifier="blabla2"> and I'm using VB.net, doing something like this: name = xmlstring.<element>.@customer-name This doesnt work, because you cannot enter "@customer-name" in the LINQ query. Is there way to escape minus sign becoming an operator? ...

How can i create such a xml hieararcy ?

I want to create dynamic XML hieararchy but still couldn't be successful about it.I tried LinqToXml classes and XML classes but still i couldn't. I want to create such a hierarchy in a loop dynamically. Create root node <Root></Root> Then add child for it. <Root> <Biggest></Biggest> </Root> Then add child for last added node <Ro...

LinqToXml OR Xml ?

Hello everybody I am trying to processing on xml and i am so tired to work with Xml namespace classes. I found it really hard. So i am trying to do same things with LinqtoXml classes and i see that many things possible with LinqtoXml instead of Xml classes. So i really get confused which i have to use. When and why do u prefer Xml ...

AppendChild and Specified method is not supported exception .

Below code gives this error message "Specified method is not supported". But here is sample which is same with mine. FileInfo file = new FileInfo("../../file.xml"); XDocument xfile = XDocument.Load(file.FullName); XPathNavigator nav = xfile.CreateNavigator(); nav.AppendChild("<pages>100</pages>"); ...

C# Linq findind the data based on a previous node

Hi Using linq xml in c# how would I extract in for a given predecessor of SetSeg with a certain value in Eg seatseg num =10 the following Seatassignment loc=?? <top> <SeatSeg> <Num>9</Num> </SeatSeg> <SeatAssignment> <Loc>032A</Loc> </SeatAssignment> <SeatSeg> <Num>1...