I have an old system that uses XML for it's data storage. I'm going to be using the data for another mini-project and wanted to use LINQ to XML for querying/updating the data; but there's 2 scenarios that I'm not sure whether I need to handle myself or not:
1- If I have something similar to the following code, and 2 people happen to hit...
Hi!
Here's what I'm trying to do. I'm querying an XML file using LINQ to XML, which gives me and IEnumerable<T> object, where T is my "Village" class, filled with the results of this query. Some results are duplicated, so I would like to perform a Distinct() on the IEnumerable object, like so:
public IEnumerable<Village> GetAllAlliance...
Using C# how should I go about extracting titles subtitles and paragraphs from a docx document.
I am thinking of doing this through VSTO but do know know the word object model. I am only familiar with the Excel object model.
Should I take the unzip + linq to XML approach ?
Using VSTO i could build an addin which could be used to edit ...
We utilise a third party web service that returns XML which looks something like (cut down for brevity):
<Response>
<block name="availability">
<block name="cqual">
<a name="result-code" format="text">L</a>
</block>
<block name="exchange">
<a name="code" format="text">MRDEN</a>
</block>
<block name="mqu...
Hi,
I have an xml file from which I am extracting html using LINQ to XML. This is a sample of the file:
<?xml version="1.0" encoding="utf-8" ?>
<tips>
<tip id="0">
This is the first tip.
</tip>
<tip id="1">
Use <b>Windows Live Writer</b> or <b>Microsoft Word 2007</b> to create and publish content.
</tip>
<tip id="2">
Enter a <b...
Hi!
I have a similar scenario as this one:
public class TestLinq2Xml
{
private XElement GenerateSomeXml()
{
return XElement.Parse(@"<MyObject>
<Properties>
<Name>My object 1</Name>
<Position>0; 0; 0</Position>
...
I am using the (.NET 3.5 SP1) System.Xml.Linq namespace to populate an html template document with div tags of data (and then save it to disk). Sometimes the div tags are empty and this seems to be a problem when it comes to HTML. According to my research, the DIV tag is not self-closing. Therefore, under Firefox at least, a <div /> is ...
Hello,
I am new with learning the possibilities of Linq to XML and I recently have found that I can query an xml like a data base (I am quite fascinated by it now).
My question is How can I query an xml file and save the result in another xml file?:
string url = "employees.xml";
XElement employees= XElement.Load(url);
if (emplo...
Does anyone know how to generate an XSD using LinqToXml? I can't find any examples of this anywhere. The XSD will be of the following fairly low level of complexity:
<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio 6.1.18.0 - FREE Community Edition (http://www.liquid-technologies.com)-->
<xs:schema
ele...
I built a template-based document generator using the Open XML SDK (1.0), the Word 2007 Content Control Toolkit and LINQ to SQL (using the CodeSmith PLINQO templates). To do this, I serialized the LINQ to SQL entities to XML by retrieving the entity using DataLoadOptions specified in the source code.
This works great, except that to ini...
How do I get just the children of an XElement?
I am currently using the XElement.Descendants() function, which returns all levels of XElements, rather than jus the child nodes.
What I would really like is an IEnumerable of just the children.
...
How do I add a second item to order by with this?
I want to order by a goalsScored element too.
var theteams =
(from teams in xdoc.Descendants("team")
orderby (int)teams.Element("points") descending
select
new Team(teams.Element("teamID").Value,
(int)teams.Elem...
I'm currently working on a Silverlight app and need to convert XML data into appropriate objects to data bind to. The basic class definition for this discussion is:
public class TabularEntry
{
public string Tag { get; set; }
public string Description { get; set; }
public string Code { get; set; }
public string U...
I need to union two sets of XElements into a single, unique set of elements. Using the .Union() extension method, I just get a "union all" instead of a union. Am I missing something?
var elements = xDocument.Descendants(w + "sdt")
.Union(otherDocument.Descendants(w + "sdt")
.Select(sdt =>
...
On e of my current requirements is to take in an Excel spreadsheet that the user updates about once a week and be able to query that document for certain fields.
As of right now, I run through and push all the Excel (2007) data into an xml file (just once when they upload the file, then I just use the xml) that then holds all of the nee...
Given this XML:
<element>Circles & boxes</element>
What I would like to do is store the string value of the element as a string, with all of the character references and entities resolved to their equivalent unicode characters. So, for this element, I would want "Circles & Boxes."
When I do this (text is an XText object represen...
I'm writing a PowerShell script to manipulate some Windows Installer XML (WiX). I'm using the new XML APIs in .NET 3.5 to do this, as I find it an easier API to work with than the DOM. The following script fragment is flatly refusing to work:
[System.Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq") | Out-Null
# Basic ide...
What (if any) is the difference between the results of the following two versions of this VB Linq query?
' assume we have an XElement containing employee details defined somewhere else
Dim ee = From e In someXML.<Employee> _
Select New With {.Surname = e.<Surname>, .Forename = e.<Forename>}
and
Dim ee = From e In someXML.<Employee> ...
Im having trouble generating XML along the lines of this:
<Root xmlns:brk="http://somewhere">
<child1>
<brk:node1>123456</brk:node1>
<brk:node2>500000000</brk:node2>
</child1>
</Root>
This code get me most of the way but I cant get the 'brk' namespace infront of the nodes;
var rootNode = new XElement("Root");
rootNode....
I have an xml file that looks like the following. What I'm trying to do is to create a query that selects only the items with the attribute "Channel" and the value "Automotive".
<item>
<title>Industries</title>
<category type="Channel">Automotive</category>
<category type="Type">Cars</category>
<category type="To...