I have the following code:
var columnNames = (from autoExport in dataContext.AutoExports
where autoExport.AutoExportTemplate != null
&& ContainsColumn(autoExport.AutoExportTemplate, realName)
select GetDbColumnNames(autoExport.AutoExportTemplate, realName)).ToList();
Where the function G...
Hi,
i'm about to read some xml (who isn't :-))
This time however it's a lot of data: about 30,000 records with 5 properties, all in one file.
Till now I've always read that the XmlTextReader is the fastest way to read xml data, but now there also is the (nice sytax of) LINQ to XML.
Does anybody know any performance issues, or that the...
Hi there,
I'm loading from a xml some information about city's points of interest, and my xml structure looks like this:
<InterestPoint>
<id>2</id>
<name>Residencia PAC</name>
<images>
<image>C:\Pictures\Alien Places in The World\20090625-alien11.jpg</image>
<image>C:\Alien Places...
Hey all
I need so generate XML like the following:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<url>
<loc>http://www.xyz.eu/</loc>
<lastmod>2010-01-20T10:56:47Z</lastmod>
<c...
I have the same problem as stated in this question, but the accepted solution there was a "works on my machine" answer.
Here is my code:
Dim document As XDocument = _
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="h...
I'm writing a program in C# that will go through a bunch of config.xml files and update certain elements, or add them if they don't exist. I have the portion down that updates an element if it exists with this code:
XDocument xdoc = XDocument.Parse(ReadFile(_file));
XElement element = xdoc.Elements("project").Elements("logRotator")
...
Currently I'm generating UserControls as follows in an abstract base class so they are available for any other pages that implement the base class:
// doc is an XML file that may or may not contain a TopStrapline node
var pageControls = new {
TopStrapline = (from strap in doc.Elements("TopStrapline")
...
I have the following XML:
<PerformancePanel page="PerformancePanel.ascx" title="">
<FundGroup heading="Net Life Managed Funds">
<fund id="17" countryid="N0" index="24103723" />
<fund id="81" countryid="N0" index="24103723" />
<fund id="127" countryid="N0" index="24103722" />
<fund id="345" countryid="N0" i...
I'm wondering if there is a robust and graceful way using linq2xml to query an item deep within an xml hierarchy. For example:
<?xml version="1.0" encoding="utf-8" ?>
<data>
<core id="01234">
<field1>some data</field1>
<field2>more data</field2>
<metadata>
<response>
<status code="0"...
hi. i want to generate XML for the following tree type structure. i attached picture. generated xml should be
<services>
<service>
<name>Service 1</name>
<categories>
<category>
<name>Cateogry 1</name>
<methods>
<method>
<name>Method 1</name>
</method>
</methods>
...
In the following code I am using XPath to find all of the matching nodes using XPath, and appending the values to a StringBuilder.
StringBuilder sb = new StringBuilder();
foreach (XmlNode node in this.Data.SelectNodes("ID/item[@id=200]/DAT[1]/line[position()>1]/data[1]/text()"))
{
sb.Append(node.Value);
}
return sb.ToString();
How...
hi everybody,
I am new in LINQtoXML. I want to use XElement.Load("") Method. but the compiler can't find my file. can you help me to write correct path for my XML file?
Note that: I defined a Class in App_Code and I want to use the XML file data in one of methods and my XML file Located in App_Data.
settings = XElement.Load("App_Data/Ap...
Hi folks,
I have a question regarding Linq to XML queries and how we could possibly make them more readable using the new dynamic keyword.
At the moment I am writing things like:
var result = from p in xdoc.Elements("product")
where p.Attribute("type").Value == "Services"
select new { ... }
What I would lik...
I've written a code generator, that generates C# files. If the file being generated is new, I need to add a reference to it to our .csproj file. I have the following method that adds a node to a .csproj file.
private static void AddToProjectFile(string projectFileName, string projectFileEntry)
{
StreamReader streamReader = new Strea...
Hi,
These two LINQ to XML methods seem to be doing the same thing. Would like to know the difference between the two.
var xdoc = XDocument.Load(filename);
xdoc.Root.FirstNode.ElementsAfterSelf();
xdoc.Root.FirstNode.NodesAfterSelf();
Both return methods return
<Title Name="Cooking with Computers: Surreptitious Balance Sheets" Price...
I have an xml in the following format where action type=0 is the default settings. Actiontype 1 and 2 are override settings. So whenever Type 1 or Type 2 settings are available in the xml they should override the default settings.
To override the field id's of the default type=0 I am trying to do a join with the field id of override typ...
<root xmlns:h="http://www.w3.org/TR/html4/"
xmlns:f="http://www.w3schools.com/furniture">
<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>
I am trying to practice Li...
I have the following XML structure:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root xmlns:xsi="My Program">
<NotRoot Text="Hello">
<SomeOption Text="Option 1" Centered="False">
<SomeOption Text="Option 1.1" Centered="False">
<SomeOption Text="Option 1.1.1" Centered="false">
...
When it comes to storing SQL in code, most people use strings:
Dim strSql As String = "Select Foo, Bar From FooBarTable Where Something = @Something"
The problem is, when you have very long SQL strings, reading them in code becomes difficult. You can usually split the strings up like this:
Dim strSql As String = "Select Foo, Bar From...