linq-to-xml

Need Simple way to access XML in VB.Net - Pain with Linq-to-Xml

Dim myXDoc As XDocument = _ I want to access this in a simple way in VB.Net - Like: Dim Integer SizeXStr = CInt(MyZDoc.Cameras(1).Camera_Desc.@SizeX) ' where (1) is an index Why isn't this ...

XElement Sorting

Hi there, I have a xml file like that: <Users> <User> <Adress Name="bbbb"/> <Adress Name="aaaa" /> </User> </Users> I want to sort User element's nodes asc. How can i order Adress elements? Thank you for your helps. ...

How to Load XML Into Workable Object From Fragment String?

I have a framgment of XML (just a few nodes, not a complete XML document) in a string that I need to get some values out of with Linq to XML. I'm finding it quite difficult to get this string into an XML object that I can work with though. Is there a way for me to do this? This is a sample of the XML: <Batch type="My Funds" pageNumber...

Using LINQ to XML, how can I join two sets of data based on ordinal position?

Using LINQ to XML, how can I join two sets of data based on ordinal position? <document> <set1> <value>A</value> <value>B</value> <value>C</value> </set1> <set2> <value>1</value> <value>2</value> <value>3</value> </set2> </document> Based on the above fragment, I would li...

Linq to XML Document Traversal

I have an xml document like this: <?xml version="1.0" encoding="utf-8" ?> <demographics> <country id="1" value="USA"> <state id ="1" value="California"> <city>Long Beach</city> <city>Los Angeles</city> <city>San Diego</city> </state> <state id ="2" value="Arizona"> ...

How do i parse the new wow RSS feed? (LINQ to XML)

The link i want to parse is here. I'm looking to parse it in "real time" so that as things happen i can send myself messages/tweets and what not. I plan on having each element of the XML from the feed as an item of a class/struct. I'm really looking for LINQ to XML examples, and a good book. I've seen other LINQ to XML articles out th...

Insert XElements using LINQ Select?

I have a source piece of xml into which I want to insert multiple elements which are created dependant upon certain values found in the original xml At present I have a sub which does this for me: <Extension()> Public Sub AddElements(ByVal xml As XElement, ByVal elementList As IEnumerable(Of XElement)) For Each e In elementList ...

LINQ to XML return second element

I'm trying to return to the second <link> element in the XML from Flickr. This always returns the first element: ImageUrl = item.Element(ns + "link").Attribute("href").Value, And this fails? ImageUrl = item.Elements(ns + "link")[1].Attribute("href").Value, ...

Linq to XML Read and output XML generated from lookup list

I am trying to use XML created from a lookup list in SharePoint as a datasource for a treeview. It is in the form of : <NewDataSet> <test_data> <ID>1</ID> <Title>MenuItem_1</Title> <child_of /> </test_data> <test_data> <ID>2</ID> <Title>Subitem_1</Title> <Action>http://www.google.com&lt;/Action&gt; ...

Complex sorting of XML subnodes in .Net3.5 onwards

XML structure expressed in Xpath kind of Records/Record/Actions/Action/ActionDate the other node on the same level Records/Record/Actions/Action/CTCDate Is there easy or not easy way to sort it on "order by ActionDate,CTCDate" ( in SQL notation ), but per Actions for each selected Record ( not per XML file ) when we iterate somehow...

Loading XML from Web Service

I am connecting to a web service to get some data back out as xml. The connection works fine and it returns the xml data from the service. var remoteURL = EveApiUrl; var postData = string.Format("userID={0}&apikey={1}&characterID={2}", UserId, ApiKey, CharacterId); var request = (HttpWebRequest)WebRequest.Create(remoteURL); request.M...

How can I get a List<int> from LINQ to XML that produces List<List<int>> ?

I have an XML snippet as follows: <PerformancePanel> <LegalText> <Line id="300" /> <Line id="304" /> <Line id="278" /> </LegalText> </PerformancePanel> I'm using the following code to get an object: var performancePanels = new { Panels = (from panel in doc.Elements("PerformancePanel") ...

LINQ-to-XML to DataGridView: Cannot edit fields -- How to fix?

I am currently doing LINQ-to-XML and populating a DataGridView with my query just fine. The trouble I am running into is that once loaded into the DataGridView, the values appear to be Un-editable (ReadOnly). Here's my code: var barcodes = (from src in xmldoc.Descendants("Container") where src.Descendants().Count() > 0 ...

XML Reader or Linq to XML

I have a 150MB XML file which used asDB in my project. Currently I'm using XMLReader to read content from it. I want to know it is better to use XMLReader or LinqToXML for this scenario. Note that I'm searching for an item in this xmland display search result, soitcan be take along or just a moment. ...

C# LINQ to XML missing space character.

I write an XML file "by hand", (i.e. not with LINQ to XML), which sometimes includes an open/close tag containing a single space character. Upon viewing the resulting file, all appears correct, example below... <Item> <ItemNumber>3</ItemNumber> <English> </English> <Translation>Ignore this one. Do not remove.</Translation> </Item>...

LINQ to XML query help needed

<Fields> <Field> <Company>My Company</Company> </Field> <Field> <Address2>Villa at beach</Address2> </Field> <Field> <Email2>[email protected]</Email2> </Field> <Field> <Mobile>333-888</Mobile> </Field> <Field> <ContactMethod>Facebook</ContactMethod> </Fiel...

Databinding question: DataGridView <=> XDocument (using LINQ-to-XML)

Learning LINQ has been a lot of fun so far, but despite reading a couple books and a bunch of online resources on the topic, I still feel like a total n00b. Recently, I just learned that if my query returns an Anonymous type, the DataGridView I'm populating will be ReadOnly (because, apparently Anonymous types are ReadOnly.) Right now, ...

linq to xml and namespaces

I'm always so excited to get a chance to use linq to xml and then I run into the same PITA issue with namespaces. Not sure what is wrong with me but I can never quite grok what is going on. Basically I just need to get the value of the responseCode element and so far I have had no luck :( <?xml version="1.0" encoding="IBM437"?> <soape...

Handling xml files with different structures and different names

I have a method and I want different users to pass me xml files. These files will have different names for the elements I am looking for and the elements I am looking for maybe at different structures. My first impression was that we should just tell them to pass in the xml in a standard format. However this is how they have their dat...

Linq To Xml problems using XElement's method Elements(XName)

Hello everyone. I have a problem using Linq To Xml. A simple code. I have this XML: <?xml version="1.0" encoding="utf-8" ?> <data xmlns="http://www.xxx.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xxx.com/directory file.xsd"> <contact> <name>aaa</name> <email>[email protected]</email> <birt...