linq-to-xml

Searching in xml with linq

hi there. I want to searching in a xml file. this is my linq sentece. string _sSemptom = "try"; XElement xe = from c in xdSemptom.Elements().Elements().Elements() .Elements().Attributes("Isim") where c.Value.Length >= _sSemptom.Length && c.Value.Contains(_sSemptom) ...

Does StreamWriter work inconsistently with relative paths?

I am trying to save a LINQ XML document using a StreamWriter. Using the following code works fine when the document is small (~6kb on disk) but doesn't work when the file is larger (~66kb on disk). If I replace the relative path with an absolute path it works fine in both situations. Is there any reason why the relative path should fail ...

Write an XML-File with LINQ to XML

Hi there, i`ve got a little problem with LINQ. I read out some information via XML-RPC. Parsing the Method-Response is no problem, but I dont no how to write the Data correctly in a new XML-File. Here`s my Code so far: var confs = from x in file.XPathSelectElements("//member[name='conferenceType'][value = 'active']" ...

Returning Element value deep inside XDocument

I have the following XML and I have been trying Descendents().Descendents().Descendents to retrieve an element value but I can't get it to work. I want to return the first value found in the first element of PersonID. It is a string so I am doing this: XDocument XDoc = XDocument.Parse(XmlString); <Root> <Code>200001</Code> <MsgTy...

Create a deep object graph with Linq to XML, refactoring?

I am writing a simple XML file parser using LINQ to XML. I want to have a TreeNode object (i.e a simple Tree structure) for each element in the XML. I want each element to be strongly typed. It looks ugly and redundant compared to the simple looping approach I was using before (using System.XML). Is there a way to strip out the redund...

Linq to XML and multiple transforms

Hi, I'm having trouble groking something in Linq - maybe someone can give me some tips. I have XML that I need to transform to new XML. The problem with this is that it is I need several iterations of transformation to get it right. The source would look something like this: <Meals> <ketchup/> <steak/> <mustard/>...

How to use LINQ to get method name and namespace in a soap request?

Hi, How to extract method name and namespace from this xml using LINQ to XML? <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/add...

XPathSelectElement vs Descendants

I was wondering if there are any performance differences when using simple queries as: var x = document.XPathSelectElement("actors/actor") vs var x = document.Descendants("actors").Descendants("actor") ...

LINQ use with XML

Hi! We have a project in which access the DB layer (MS SQL) with LINQ. Can we now change our DB layer to XML file and still access it with the same LINQ? We want add possibility to store data in a single XML file or a set of XML files. Current LINQ to SQL code looks like: result = (from e in db.Organizations where e.Id == id...

Find XElement by Attribute value

Hi all, I have a collection of IEnumerables and each one has a different attribute values that corresponds to a different property on my business object. Here is a sample of the XML that I am querying against: <SimpleData name="zip">60004</SimpleData> <SimpleData name="name">ARLINGTON HEIGHTS</SimpleData> <SimpleData name="state"...

LINQ to XSD in Visual Studio 2010 Beta2

I've been looking around and I was wondering if this is available in VS10 beta2. So far all I've seen is the Linq to XSD alpha 0.2 preview that works for VS 2008 ...

Reading and navigating a xml dataset file

The xml dataset file after I add it to a dataset like this: <?xml version="1.0" standalone="yes"?> <root> <Email></Email> <FirstName></FirstName> <LastName></LastName> <Addresses> <item> <Address1></Address1> </item> <item> <Address1></Address1> </item> </Addresses> <Friends> <item> <Name></Name> <...

Linq to XML - remove a node and add a new node at same place

I have an XDocument and have to remove a node and add the very same node back again after some manipulation(my xelement node are complex and have inner nodes as well). Has anyone got a good way to do this as my new manipulated node is being added at the very end of the xmldocument. Any code snippets would be greatly appreciated. ...

Read DBML xml with LINQ to SQL

Hi All, I want to iterate through the tables in a dbml's xml. But i'm struggling to get to the Type elements. How would I do it using LINQ to SQL? ...

Linq to XML. Selecting Multiple columns

Dim MyQuery = From c In xdoc.Descendants() _ Where c.Attribute(OriginY) IsNot Nothing _ Order By Val(c.Attribute(OriginY).Value), Val(c.Attribute(OriginX).Value) _ Select c.Attribute(UniStr) Right above you can see my First! linq attempt! And here comes my first question. How can i select more than one column in a linq query in vb.net...

Linq namespace issue

I can seem to get any records from the following xml. xmlns="http://www.w3.org/2005/Atom" If i remove the above it works <?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"&gt; <entry><id><![CDATA[text]]></id>< author><name><![CDATA[film24]]></name></author><t...

What is the equivalent to InnerText in LINQ-to-XML?

My XML is: <CurrentWeather> <Location>Berlin</Location> </CurrentWeather> I want the string "Berlin", how do get contents out of the element Location, something like InnerText? XDocument xdoc = XDocument.Parse(xml); string location = xdoc.Descendants("Location").ToString(); the above returns System.Xml.Linq.XContainer+d_...

XDocument producing invalid XML

I have this code Dim doc As XDocument = New XDocument( _ New XDeclaration("1.0", "utf-8", "yes"), _ New XElement("transaction", _ New XElement("realm", wcRealm), _ New XElement("password", wcPassword), _ New XElement("confirmation_email", wcConfEmail), _ New XElement("force_subscribe", wcSubscribe), _ New XElem...

XML to LINQ Question/s

Hello, Just before I begin heres a small overview of what I'm trying to achieve and then we'll get down to the gory details. At present I'm developing an application which will monitor a users registry for changes to specific keys which relate to user preferences. Were currently using mandatory profiles (not my choice), anyway the whole...

linq to xml select

hi i have an xml like this <?xml version="1.0"?> <DataSetExchangeWMS xmlns="http://tempuri.org/DataSetExchangeWMS.xsd"&gt; <dtObjektInfo> <LanguageCode>1031</LanguageCode> <LiegenschaftID>7463</LiegenschaftID> </dtObjektInfo> 1040 7463 09 Now as i learned from tutorial i get my xml file and select nod...