So I started learning XLinq last evening and I thought I would try to parse a samle RSS document like found at http://weblogs.asp.net/scottgu/rss.aspx
My test was to find all entries which fit the following criteria
a) Was Posted in the year 2008
b) Had atleast one comment
c) Had the tag ".NET"
So I am wondering if my solution(though ...
Hi! I'm parsing big XML file with XPathExpression selection for some nodes existing at various depth levels.
What is the easiest way to export selected nodes to separate XML file, preserving all direct-ancestors nodes (and their attributes)? C# is preferred.
Example source XML :
<a>
<x>
<b>
<c/>
<z/>
</b>
<c/>
</a>
<c/...
I'm trying to use System.Xml.Linq to create XHTML documents. Thus, the vast majority of the nodes in my trees ought to use this namespace:
http://www.w3.org/1999/xhtml
I can create XElement nodes scoped to this namespace easily enough, using an XNamespace, like this:
XNamespace xhtml = "http://www.w3.org/1999/xhtml";
// ...
new XElem...
When I realized I needed to create an index for approximately 50 XHTML pages, which may be added/deleted/renamed/moved in the future, I thought "No problem -- I'll write a quick index generator using LINQ to XML, since XHTML definitely counts as XML".
Of course, as soon as I tried running it, I found out about the fact that XLINQ choke...
The .Net framework now has (at least) four different methods of reading an Xml string. I've used each of XmlDocument, XmlReader, XPath and XElement, but which is the most efficient to use when coding or during execution? Is each designed for a different task, what are the pros and cons?
Update:
Using a XmlReader appears to be the quic...
Hi,
when I subclass from XElement, the DataTemplate that works for XElement using the element name as DatatType, doesn't work for the subclass. Any idea?
<HierarchicalDataTemplate DataType="grupo" ItemsSource="{Binding Path=Elements}">
<TextBlock Text="{Binding Path=Attribute[name]}" />
</HierarchicalDataTemplate>
<!-- When I bu...
How do I generate, based on a xsd and c#, an xml containing only the mandatory elements. I would prefer to use xlinq but I am also open to alternatives.
...
i am creating xml using linq.xml through xelement.
my hirerachy is some thing like this
I want this schema
2
str
here is my code for schema generation
XNamespace Namespace = XNamespace.Get("urn:APISchema.xsd");
root = new XElement(namepsace + "Foo");
root.Add(new XElement("version", "2"));
root.Add(new XElement("...
I'm using Visual Web Developer to build a Silverlight Class Library. I have another project where the Class Library is imported and implemented. It's loading an XML file and I'm using XmlSerializer.Deserialize into a class I created with xsd.exe.
Sometimes, when loading the XML, I get this error:
Unhandled Error in Silverlight 2 Appl...
I'm writing a program to parse some third-party XML files. The structure is something like...
<CharacterSheet>
...
<StatBlock>
...
<Stat>
...
<alias />
...
</Stat>
...
</StatBlock>
...
</CharacterSheet>
I'm using this in to get some practice with linq, and I'm fining I have to write some really ugly chained querie...
Elements and FirstAttribute bind as I'd expect (if I didn't know it's a method), but Attributes does not, despite being a member of XElement, just like the others. I know about IValueConverter, and I'm using that to get the binding I want on attributes, but I'm curious as to why it works on Elements.
<Window x:Class="WpfApplication6.Win...
I was pleasantly surprised a few months ago to learn that I could use many C# 3.x constructs (anonymous types, lambdas, automatic properties) in C#2.0, due to the fact that they all compile to the same IL...in effect, syntactic sugar.
Is this also the case of LINQ and XLINQ? Can i use these constructs while still targeting C#2.0 runtim...
I have a result of a xlinq that is an enumerable with id and phones, I want to transform that to a Dictionary, that part is simple, however the part of transforming the phone numbers from a XElement to a string its proving hard
xLinqQuery.ToDictionary(e => e.id, e => e.phones.ToList());
will return Dictionary<int, List<XElement>> what...
I'm doing some transforms using xlinq and some of those transforms can result in leaving empty elements in the document.
Once I am done all of those transforms, how can I query an xdocument for all empty elements?
In other words; if I remove all <a> tags which happen to be the only element inside an <li> tag, how do I remove the empty...
As a part of trying to repair stuff in a fairly messed up legacy system I have a method making a call to a stored procedure in our SQLServer database. Nothing in this set up is ideal, but it is what I have got to work with. The two options I have is to use a SqlDataReader to read the stream as rows from the database, or to be handed the ...
How do I create/read/write XLinq and/or VB XML Literals from and to encrypted xml files?
...
I forgot casting mechanism when i encounter it :) . So can u make me remember it again ? Because it looks not acceptable for me at the moment.
...
So I want to access the child element in a structure that looks like this:
<asdf:foobar attr="value">
<child>...</child>
</asdf:foobar>
I forget what the asdf is called, but it is what's causing the problem. My normal method of traversing in XLinq doesn't work:
xElem child = xDoc.Element("foobar");
Sets child to null because it...
In a Windows Form application, I'm trying to create a DataGridView with two columns: one for the key given by an XML element and one for the value of said XML element. This is my code so far:
this.myData = new DataGridView();
((System.ComponentModel.ISupportInitialize)(myData)).BeginInit();
myData.Location = new...
My code is as bellow ,i have a xml file in xml folder in root i get an error type or namespace Movie not found.
I think i am following what wrox book has said i get this error,can anyone help me out.
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System...