I have a XElement that has the following structure
<document num="1">
<pages>
<page />
<page />
</pages>
</document/>
I have one Listbox named "documents" that is bound to an XElement in the following manner:
ItemsSource="{Binding Path=TheXElement.Elements[document]}"
I want to have a second ListBox named "pages" whose Ite...
I have some XML that I deserialize into a business object. I am using XmlSerializer.Deserialize to do so. However, I want one of the XmlElement contained in the XML to stay an XElement.
It cannot be done directly (using an XmlElementAttribute) since XElement is not Serializable. I also tried to serialize that element to a string (in ...
I'm passing an XElement to my Edit view and want to have the usual HTML controls built for me and correctly named. The code I have is:
...
<div class="editor-label">
<%= Html.LabelFor(model => Model.XPathSelectElement("site[@id = 'customerName']").Value)%>
</div>
<div class="editor-fie...
I have an XElement and I need to add more elements to it from a string. The string contains multiple xml elements in it that I need to parse. I have tried both XDocument.Load and XElement.Parse but get errors. The contents of the file are as follows:
<menu id="a">
<menuItem keyID="0">
<command>test</command>
</menuItem>
<menu...
I can't seem to find anything other than XDocument.Descendants () in the documentation. Is there any way to do this?
...
I want to read a large xml file (100+M). Due to its size, I do not want to load it in memory using XElement. I am using linq-xml queries to parse and read it.
What's the best way to do it? Any example on combination of XPath or XmlReader with linq-xml/XElement?
Please help. Thanks.
...
I am parsing a large xml file. So I am using an XmlReader in combination with XElement instead of XElement.Load().
I have created as XElement object from XmlReader as shown below and here.
static IEnumerable<XElement> StreamRootChildDoc(string uri)
{
using (XmlReader reader = XmlReader.Create(uri, xmlReaderSettings))
{
...
My xml looks like:
<nodes>
<node name="somekey">
<item name="subject">blah</item>
<item name="body">body</item>
</node>
</nodes>
And my code so far is:
XDocument doc = XDocument.Load(HttpContext.Current.Server.MapPath(String.Format("~/files/{0}/text.xml", "en")));
if (doc != null)
{
XElement element = doc.Elements().Where(e => e...
So I'm trying to parse an xml file:
<?xml version="1.0" encoding="utf-8" ?>
<Root>
<att1 name="bob" age="unspecified" xmlns="http://foo.co.uk/nan">
</att1>
</Root>
Using the following code:
XElement xDoc= XElement.Load(filename);
var query = from c in xDoc.Descendants("att1").Attributes() select c;
foreach (XAttr...
Hi folks,
i have a simple xml file in a wcf service that i am trying to load using Xelement.Load("sample.xml") which is not reading the file. What's the right way of doing this?
The service is supposed to return an xml to an asp.net application.
TIA
...
Hello,
I am trying to validate Elements and Attributes exist in an XElement. Basically, I was wondering if anyone had a generic way to check if a give path is null. I don't have access to System.Xml.XPath (doing this for compact framework).
Basically what I have is:
<root value"1000">
<element1>test<element1>
<element2>1<element...
I'm populating an XElement with information and writing it to an xml file using the XElement.Save(path) method. At some point, certain characters in the resulting file are being escaped - for example, > becomes >.
This behaviour is unacceptable, since I need to store information in the XML that includes the > character as part of a ...
Can anyone explain why the original address XElement street node changes? It looks like customer1 holds a reference to the address XElement but customer2 and customer3 have taken copies.
Why did the original address change? (LINQPad example)
var address =
new XElement ("address",
new XElement ("street", "Lawley St"),
...
How can I recursivly bind a Treeview to an XDocument, mapping each XML Element to a Node in the Treeview?
The code below should work from my perspective (and also according to the very few posts I found regarding direct binding), however it does not:
<sdk:TreeView ItemsSource="{Binding Path=Elements}" DataContext="{Binding Path=Data}">...
How do I get Linq to ignore any parameters that are empty? So Lastname, Firstname, etc? If I have data in all parameters it works fine...
refinedresult = From x In theresult _
Where x.<thelastname>.Value.TestPhoneElement(LastName) And _
x.<thefirstname>.Value.TestPhoneElement(FirstName) And _
...
I have a source piece of xml into which I want to insert multiple elements which are created dependant upon certain values found in the original xml
At present I have a sub which does this for me:
<Extension()>
Public Sub AddElements(ByVal xml As XElement, ByVal elementList As IEnumerable(Of XElement))
For Each e In elementList
...
Hi everyone,
I get an ArrayOfXelement for a result by a webservice. But now I wish to bind this data into a chart in Silverlight also I need to create a datatable.
My question is how to travel my ArrayOfXelement ? Any ideas ? Linq to XML ?
Regards.
Narglix
...
Hello everyone. I have a problem using Linq To Xml.
A simple code. I have this XML:
<?xml version="1.0" encoding="utf-8" ?>
<data xmlns="http://www.xxx.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xxx.com/directory file.xsd">
<contact>
<name>aaa</name>
<email>[email protected]</email>
<birt...
I have such XML
<root>
<content>
....
</content>
<index>
....
</index>
<keywords>
....
</keywords>
</root>
But I need to select just and nodes.
<content>
....
</content>
<index>
....
</index>
I found out how to select just one node.
XElement Content = new XElement("content"...
Hi,
Can anyone please guide me on how to use XElement in Silverlight (C#) to read an XML file.
Thank You!
...