Hi,
Can I use Linq-to-xml to persist my object state without having to use/know Xpath & XSD Syntax?
ie. really looking for simple but flexible way to persist a graph of object data (e.g. have say 2 or 3 classes with associations) - if Linq-to-xml were as simple as saying "persist this graph to XML", and then you could also query it via...
Let's take this xml structure as example:
<?xml version="1.0" encoding="utf-8"?>
<Configuration-content>
<XFile Name="file name 1" />
<XFile Name="name2" />
<XFile Name="name3" />
<XFile Name="name4" />
</Configuration-content>
C# interface to implement:
public class Configuration
{
public XFile[] Files { get; set; }
}
p...
Given the following code:
string xml = "";
//alternativley: string xml = "<people />";
XDocument xDoc = null;
if (!string.IsNullOrEmpty(xml))
{
xDoc = XDocument.Parse(xml);
xDoc.Element("people").Add(
new XElement("person", "p 1")
);
}
else
{
xDoc = new XDocum...
Updated to be clear.
Step One: I have a XML file that I want to load into a DatGridView. (Mostly working thanks to Max, but I still have a problem with the XML rollup)
Step Two: Run some code based on user input -- (not part of this solution)
Step Three: Export the DataGridView into a CSV File. (Solved by Max! Thanks Man That was...
I am learning Windows Forms in C#.NET 2008 and i want to build a class to work with SIMPLE xml files (config file like INI files), but i just need a simple class (open, getvalue, setvalue, creategroup, save and close functions), to substitute of ini files.
I already did something and it is working but I am having trouble when I need to ...
I have a table of data that looks something like this.
name, hour, price1, price2, price3, price4, price5
fred, 3, 12.5, 13.5, 14, 15, 16
dave, 6, 8, 12, 18, 20.2, 25
fred, 6, 10, 11, 14, 15, 19.7
This table needs to be output to an xml file that looks like this.
<timeCost>
<person name="fred">
<time hour="5">
<cost price...
Hi guys
In the context of the n-tier application, is there a difference between what you would consider your data access classes to be and your repositories?
I tend to think yes but I just wanted to see what other thought. My thinking is that the job of the repository is just to contain and execute the raw query itself, where as the d...
Hi guys
I'm just starting a project which requires some pretty hardcore linq to xml to be used and I am just wondering what people consider best practice and lessons learnt.
For instance, I am worried about all the nulls that are possible all over the place... This is something that I am using but how do other people deal with it:
...
Hi,
I have a complex data structure, which I boiled down in a dbml file with one class and 6 one-to-many relations. This data must also be read via xml. The xml structure is something like:
<table id=1>
<column 1></column 1>
<column n></column n>
<m-n table x>
<column 1></column 1>
</m-n table x>
</table>
where t...
Getting multiple data items in an element with linq to xml
I have an xml file like this
<TopLevel>
<Inside>
Jibba
</Inside>
<Inside>
Jabba
</Inside>
</TopLevel>
I was given said xml and and want to get all the elements. Here is the code I have.
var q = from c in loaded.Descendants("TopLevel")
select (...
I want by linq save my xml in csv and I have o problem.
This bracket are here beacuse without it this code is not displaying (why ? )
<results>
<Countries country="Albania">
<Regions region="Centralna Albania">
<Provinces province="Durres i okolice">
<Cities city="Durres" cityCode="2B66E0ACFAEF78...
Hi All,
I have a xml structure similar to below one:
<test>
<test1>test1 value</test1>
</test>
Now I am reading the value of node using below LINQ to xml code.
var test = from t in doc.Descendants("test") select t.Element("test1").Value;
Console.WriteLine("print single nod...
Similar to XPath: How to match attributes that contain a certain string but without using XPath. Is it possible?
<c BarFoo="val1">
<d Foo="val2" someAttribute="">
<e FooBar="val3" />
</d>
</c>
Basically I want to select all the attribute values in the document that their attribute name contains "Foo", so it should return ...
Here I had very similar xml structure, but now I have this:
<Fields>
<Company>My Company</Company>
<Address2>Villa at beach</Address2>
<Email2>[email protected]</Email2>
<Mobile>333-888</Mobile>
<ContactMethod>Facebook</ContactMethod>
...etc...
</Fields>
And now I need the same output as on the given link:
Compan...
I have a Linq-2-XML query that will not work if a google sitemap that I have created has its urlset element populated with attributes but will work fine if there are no attributes present.
Can't query:
<?xml version="1.0" encoding="utf-8"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sit...
Here is the XML outline:
<Root>
<Thing att="11">
<Child lang="e">
<record></record>
<record></record>
<record></record>
</Child >
<Child lang="f">
<record></record>
<record></record>
<record></record>
</Child >
</Thing>
</Root>
I have the follow...
Hi all,
How do I use Linq to extract a single XML attribute form each XML file in a directory and put that element in a C# list. Do I have to loop thru each file one-by-one? The XML files are quite large so I'd like to do this without loading the entire file into memory.
Thanks,
j
...
I have a document created in a constructor, and during execution I'm filling
it in with fragments generated from Custom Business Objects.
When I'm outputting the fragments, I need to include namespace fragments, but
I'd like to avoid adding the namespace url to each fragment, since it's defined in the root.
Any thoughts?
_doc = new XD...
Please excuse my stupidity, I tend to find the traversing XML overly complicated.
I am using ASP.NET in VB.
I have an XML document which contains all the details of staff in my company...
<staff>
<staffName>Test Staff</staffName>
<staffTitle>Slave</staffTitle>
<staffDepartmentName>Finance</staffDepartmentName>
<staffOf...
I have the following XML:
<FootNotes>
<Line id="10306" reference="*"></Line>
<Line id="10308" reference="**"></Line>
<Line id="10309" reference="***"></Line>
<Line id="10310" reference="****"></Line>
<Line id="10311" reference="+"></Line>
</FootNotes>
and I have the following code where I'm to get a Dictionary<int, string>()...