0
голосов
1ответов
1657 просмотров

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...

0
голосов
1ответов
366 просмотров

Searching in xml with linq

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 && ...

5
голосов
1ответов
3249 просмотров

Linq to XML -Dictionary conversion

How to store the nodes of the following into Dictionary where int is an autogenerated Key and string (value of the node) using LINQ ? Elements: XElement instructors = XElement.Parse( @"<instructors> <instructor>Daniel...

1
голосов
1ответов
1884 просмотров

How to keep in session XML-based objects?

I'm receiving data from web-services in XML and I'm using that data via objects, build upon received XML. So, sometimes I need to store such user-specific objects between requests in session. I know that XMLDocument couldn't be stored explicitly (state server)... so I'm making a terrible construc...

1
голосов
2ответов
658 просмотров

Linq XML Dynamic building

I am building an xml file. Parts of the file are static. Some of the file is dynamic. My code has an error of “Null object reference”. Any tips would be awesome. private XElement BuildDataElement() { // this is going to be more complicated return new XElement("data"); } pu...

2
голосов
2ответов
536 просмотров

How do I generate a linq to xml infoset w/ a DTD reference?

I need to generate an xml infoset but the infoset needs to contain a reference to a client's DTD. The desired out needs to contain this DTD reference <!DOCTYPE AutoApplication SYSTEM "http://www.clientsite.com/public/DTD/autoappV1-3-level2.dtd"> This reference sits directly benath the xm...

0
голосов
2ответов
1869 просмотров

struggling with XML namespaces (linq)... what am I doing wrong here?

Trying to parse some XML but apparently this is too much for a lazy sunday afternoon, this is my code: (I Tried the XPathDocument and XmlDocument approach too but this also failed miserably) XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(postData); XDocument xDoc = XDocument.Load(ne...

3
голосов
1ответов
4705 просмотров

Return value from XPathSelectElement(s) in C#

How do node.XPathSelectElement() and node.XPathSelectElements() behave when the selection is either not a NodeSet or a NodeSet containing non-Elements? For example do they always return something or can they throw Exceptions? can the return value be null or is it always an IEnumerable of some sor...

11
голосов
1ответов
6290 просмотров

LINQ to XML: applying an XPath

Can someone tell me why this program doesn't enumerate any items? Does it have something to do with the RDF namespace? using System; using System.Xml.Linq; using System.Xml.XPath; class Program { static void Main(string[] args) { var doc = XDocument.Load("http://seattle.craigsli...

4
голосов
3ответов
1632 просмотров

LINQ to XML And Distinct Custom Class

I have a very interesting LINQ question. I have a document, that I am trying to filter results on, but to filter, I am matching on a REGEX result from one element of the XML. I have the following, working LINQ to XML to get the individual data that I'm looking for. Dim oDocument As XDocument o...

2
голосов
3ответов
1961 просмотров

How to search for a node using Linq to XML Query?

Below the xml doc <Root> <Global> </Global> <local> <section name="A"> <subsection name="A"> <innersection name="A"> <Property1> ...

3
голосов
5ответов
4810 просмотров

how to get root node attribute value using linq

I have the following XML. How to read the root node attribite value and it's decendents using LINQ? I am trying to read "dId" and "dTime" from root node, "id" from Customer element and Order number. <?xml version="1.0" encoding="utf-8" ?> <Customers dId="wqwx" dTime="10-9-09 11:23">...

1
голосов
2ответов
2162 просмотров

DeSerialize DataTable Row Collection into List<t></t>

I have a DataTable with rows of data. I have a class with properties that match the row column names. How can I have a List that is populated from the DataTable Row information? Do I call something like (MyType)new XmlSerializer(typeof(MyType)).Deserialize(new XMLReader(Table.WriteXML()));

7
голосов
3ответов
8192 просмотров

Why can't I set the XDocument XDeclaration encoding type to iso-8859-1?

Why doesn't the following code set the XML declaration encoding type? It always sets the encoding to utf-16 instead. Am I missing something very obvious? var xdoc = new XDocument( new XDeclaration("1.0", "iso-8859-1", null), new XElement("root", "") ); output: &lt;?xml version="1.0" enc...

513
голосов
7ответов
191568 просмотров

XDocument or XmlDocument

I am now learning XmlDocument but I've just ran into XDocument and when I try to search the difference or benefits of them I can't find something useful, could you please tell me why you would use one over another ?

1
голосов
2ответов
2332 просмотров

Help Merging XML Data

I have two XMLDocuments that contain some similar information but there are other nodes that contain different information between the two. I am using XMLSerialization to put my data into a structure as shown here I know you can merge XML files by using a DataSet as shown here but I want to som...

1
голосов
3ответов
262 просмотров

Is this the most efficient way of loading xml values into a structure?

I am trying to load data from XML string into a structure of some sort so once loaded I can then say Data.PropertyName to read the values. Is the below code the most optimal way of loading the data into the structure? Obviously calling First() has a memory hit so if you have elements with s...

1
голосов
2ответов
1062 просмотров

ISNULL() in LINQ to XML

SELECT * FROM CUSTOMERS WHERE RTRIM(ISNULL([SHORTNAME],'')) LIKE '%john%' I want to write this using Linq, var persons = from person in xmlDoc.Descendants("Table") where person.Element("SHORTNAME").Value.Contains("123") select new { shortName = person.Element("SHORTNAME").Value, longName =...

1
голосов
3ответов
1139 просмотров

Creating XML in C# for jQuery

I'm trying to generate some XML for a jQuery.get (AJAX) call, and I'm getting the following error from my C# page: "Using themed css files requires a header control on the page. (e.g. &lt;head runat="server" /&gt;)." The file generating the XML is a simple .aspx file, consisting entirely of: &l...

3
голосов
2ответов
944 просмотров

Silverlight 3: Converting XML stroke collection back into a strokecollection?

I have a silverlight app that allows the user to draw on it and save the drawing. The strokecollection in the canvas is converted to xml attributes and stored in the database. the only problem i have now is converting the xml back into a stroke collection. my strokes are stored as such: &lt;S...

190
голосов
7ответов
119412 просмотров

Converting XDocument to XmlDocument and vice versa

It's a very simple problem that I have. I use XDocument to generate an XML file. I then want to return it as a XmlDocument class. And I have an XmlDocument variable which I need to convert back to XDocument to append more nodes. So, what is the most efficient method to convert XML between XDocum...

0
голосов
3ответов
790 просмотров

LINQ to XML NullReferenceException AFTER returning the results?

I'm quite new to .NET and even more so to LINQ, which I have just begun exploring for a small project I'm working on. I have a XML file generated from an application that contains a few values that I want to parse into a proprietary format and save in a file. I'm able to make one LINQ query wor...

0
голосов
4ответов
3796 просмотров

XML with C# LINQ to XML

Following is the example of an XML document. &lt;People&gt; &lt;Person&gt; &lt;Name&gt;ABC &lt;/Name&gt; &lt;SSN&gt;111111&lt;/SSN&gt; &lt;Address&gt;asdfg&lt;/Address&gt; &lt;/Person&gt; &lt;/People&gt; I need to get the tag names but not the values between the tag ...

2
голосов
2ответов
700 просмотров

How do I serialise a List<t> to XML using LINQ to XML?</t>

I've this generic list List&lt;zil&gt; listKD = new List&lt;zil&gt; { new zil{day="Mon",c="1",S1="08:00",S2="08:40",S3="08:47"}, new zil{day="Mon",c="2",S1="08:50",S2="09:30",S3="09:37"}, new zil{day="Mon",c="3",S1="09:40",S2="10:20",S3="10:27"}...

0
голосов
1ответов
249 просмотров

need links to xml concepts for asp.net 3.5 web app development

We are developing a project using asp.net 3.5 and sql server 2008. I know a bit of xml like creating, loading, adding elements to xml file. I was not exposed to XML Scema, XSLT and XPath kind of stuff. And now there is LINQ to XML and LINQ to SQL also. Could anyone please provide me some good ...

2
голосов
4ответов
2250 просмотров

How can i use "like" in linq to xml

I wanna do something like this. I know it’s wrong: var a = from h in xdoc.Root.Elements() where h.Element().value like = "1234" select h;

8
голосов
3ответов
11021 просмотров

Compare two xml and print the difference using LINQ

I am comparing two xml and I have to print the difference. How can I achieve this using LINQ. I know I can use XML diff patch by Microsoft but I prefer to use LINQ . If you have any other idea I will implement that //First Xml &lt;Books&gt; &lt;book&gt; &lt;id="20504" image="C01" name="C...

2
голосов
2ответов
4869 просмотров

LINQ to XML Newbie Question: Reading xml and order by attribute

I have a noob LINQ to XML question. I have xml like so: &lt;pages&gt; &lt;page Name="Welcome" Control="Welcome" Order="1"&gt;&lt;/page&gt; &lt;page Name="Summary" Control="Summary" Order="10"&gt;&lt;/page&gt; &lt;/pages&gt; I need to read in the data and save it to an array ord...

0
голосов
1ответов
207 просмотров

LINQ to XML or SQL Server 2005 XML DML?

I'm writing an app that retrieves RSS feeds on a scheduled daily basis and saves the contents of each feed as XML Data in a SQL Server 2005 database. I want to display the aggregated items, sorted by date, for example, from the saved feed data in my app in Asp.Net GridViews. My question is: sho...

4
голосов
2ответов
20329 просмотров

LINQ-to-List and IEnumerable issues

I am querying an HTML file with LINQ-to-XML. It looks something like this: &lt;html&gt; &lt;body&gt; &lt;div class="Players"&gt; &lt;div class="role"&gt;Goalies&lt;/div&gt; &lt;div class="name"&gt;John Smith&lt;/div&gt; &lt;div class="name"&gt;Shawn Xie&lt;/di...