Browse by Tags
All Tags »
LINQ to XML (RSS)
Annotations are used for private use. It does not directly associated and known as Black Box in XML world. This can also be considered as meta tag. Below is an example on how it can be handled. I have created a sample Windows Applications and will try
Read More...
I have spent a while with LINQ and still feel very new whenever I explore some new power. Here I am going to describe you how LINQ uniformly allows you write for the various types of data. In-memory data source ++++++++++++++++ List < int > arrInt
Read More...
This question arises in one of discussions. If you have a XML document with “xmlns” then LINQ to XML does not return any IEnumerable<T> J . This is strange but true for XPath and XQuery. There is a trick to get it done, Let us assume that you have
Read More...
IEnumerable<T> and IQueryable<T> are the two most used terms of any LINQ discussion. What I am trying to here is that I am trying to simplify the two interfaces depending on their behavior. In LINQ world we generally have few providers available
Read More...
You have XML document now you want to modify that XML file using LINQ to XML. It is as easy as you generally modify any database column value. Let us create a dummy XML stream, //Create dummy XML to work var root = new XElement ( "parent" , from i in
Read More...
When you create data bind application using wizard in Windows Forms application and connection string gets added to you settings file. Now you may be interested in changing that connection string but problems, 1) The connection string in settings has
Read More...
I have written a post earlier on how to attach Namespaces . After reading my article someone complained about the redundancy of the code. I also realized the pain. I was reading the book C# 3.0 In a Nutshell. There I got a very elegant solution. Let me
Read More...
Let’s say I have created two Xml files using LINQ to XML from Northwind database. I have taken two tables Category and Products and tried to join between two different files. Category XML <? xml version = " 1.0 " encoding = " utf-8 " ?> < categories
Read More...
Based on my previous post on LINQ to XML : Working with Namespaces , if you want to add prefixes to your Xml things becomes little crazy. The trick is that you have to use XAttribute() to attach prefixes. So the Xml as below need the following code, <
Read More...
If you are working with complex real world XML then you have to deal with namespaces to disambiguate. There are several ways to implement namespaces in LINQ to XML. One is you can use pure string to add your namespace with each element declaration, like
Read More...
LINQ to XML API allows us to create complete XML document as expected with all the elements. So this X-DOM has everything as you expect. Simple sample looks like, XDocument doc = new XDocument ( new XDeclaration ( "1.0" , "utf-16" , "true" ), new XProcessingInstruction
Read More...
Based on my previous post if I have to filter the list of customers only in the country “US” and create another XML which may look like, <? xml version = " 1.0 " encoding = " utf-8 " ?> < usaCustomers > < usaCustomer > < title >
Read More...
We can generate hierarchical object graph in our memory though LINQ. To be more realistic we can bring data from relational database. So if we consider Northwind database and use LINQ to SQL to bring all the Customers and their Orders and Order Details
Read More...
XElement and XAttribute are the two very important classes available in System.Xml.Linq.dll assembly. Using these two classes you can do lot of things in the LINQ to XML world. I will show you step by step how, For just an element XElement _root = new
Read More...