so i have some inline XML
Dim x As XElement = _
<parent>
<child></child>
</parent>
what I want to do is get some variables that have been set into that xml
Dim v as string = "Blah"
Dim x As XElement = _
<parent>
<child>{v}</child>
</parent>
Is this possible? I...
Sorry to be asking such similar question again, I am trying to read the following XML document:
<markets currency="GBP">
<market id="2908368" nextId="2908395">
<status>ACTIVE</status>
<commissionRate>2.5</commissionRate>
<marketType>ANY_NUMBER_OF_WINNERS</marketType>
<selections type="MainBets">
<selection id="65...
Hi,
Maybe I'm just spoiled by SQL, but is there some cool LINQ way to insert a new record into an "XML table" and have the indexed ID update automatically (or at least semi-automatically)?
Here's what I mean by "XML table":
<myElements>
<myElement>
<id>1</id>
<value>blah</value>
</myElement>
<myElement>
<id>...
I am having trouble creating an XML document that contains a default namespace and a named namespace, hard to explain easier to just show what I am trying to produce...
<Root xmlns="http://www.adventure-works.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation="http://www.SomeLocatation.Com/MySchemaDoc.xsd">...
I have a WCF service that is returning an XElement, this is working fine however I would like it to include the XML Declaration in the response:
<?xml version="1.0" encoding="utf-8"?>
The client side is not something that I can change and is reporting a "Result is not XML" The only other differences between the response of my HTTP re...
How to add an existing Xml string into a XElement?
This code
var doc = new XDocument(
new XElement("results", "<result>...</result>")
);
of course produces this
<results><result></result></results>
but I need this
<results><result>...</result></results>
Any ideas?
...
Hi All,
I need advice. I have application that imports 10,000 rows containing name & address from a text file into XElements that are subsequently added to a synchronized queue. When the import is complete the app spawns worker threads that process the XElements by deenqueuing them, making a database call, inserting the database output ...
I am creating XML using Linq to XML and C#. It all works great except when I need to manually add in a row in the XML. This row is only added if I have a value to pass through to it, otherwise I just ignore the entire tag.
I use XElement.Load to load in the string of text that I store in a string but when I attach it to the XML it alway...
I have a string which contains XML, I just want to parse into Xelement, but it has an ampersand. I still have problem to parse it with HtmlDecode. Any suggestion?
string test = " <MyXML><SubXML><XmlEntry Element="test" value="wow&" /></SubXML></MyXML>";
XElement.Parse(HttpUtility.HtmlDecode(test));
I also added these methods to rep...
So, I have a bug to remove
foreach (XElement x in items.Elements("x"))
{
XElement result = webservice.method(x);
if (/*condition based on values in result*/)
{
x.Remove();
}
}
The problem is that calling x.Remove() alters the foreach such that if there are two Elements("x"), and the first is removed, the loop d...
I had to write my own deserializer, because XmlSerializer and DataContractSerializer aren't good for my needs. So, here's the base of my deserializer:
static BaseElement ParseXml(XElement element)
{
var e = (Element)Activator.CreateInstance(Type.GetType("Elements." + element.Name));
foreach (var attr in element....
How can I see the XML output of following C# code? I can see that it uses XElement, but where I can locate the XML file or the output?
private void Form1_Load(object sender, EventArgs e)
{
XElement doc = new XElement("searchresults"); // root element
//create
XElement result = new XElement("result",
...
When I use LINQ to XML, is the order of the elements and attributes written out to text guaranteed to be the same order as how I added the XElement and XAttribute objects? Similarly, when I read in an XML document, is it traversed in the same order as it appears in the XML?
...
Hello,
I have an issue. I have hierarchical XML data such as:
<Tree>
<Node Text="Stuff" ItemGUID="064a9bf0-0594-47f8-87be-88dd73763c77" >
<Node Text="Food" ItemGUID="326f1f7a-d364-4838-9bdc-ce5fd93f88ca" ItemType="2" />
<Node Text="Wines" ItemGUID="950e3ca3-27a1-41fd-89f3-7a8b08633a9f" />
<Node Text="Flowers" ItemGUID="ce...
Is there a way to determine if an XElement contains one of any specified elements? For example, I have XElements that I'll want to check:
Dim xe1 = <color><blue/></color>
Dim xe2 = <color><red/></color>
Dim xe3 = <color><powderBlue/></color>
Dim xe4 = <color><aqua/></color>
Dim xe5 = <color><green/></color>
I'd like to be able to quer...
Is there a way to replace all existing values from XML with values from dictionary using Linq? I'm using c#.
XML example:
<root>
<node1> <--without attribute
<subNode1>someTextValue</subNode1>
</node1>
<node2 name="myNode2"> <--With attribute (IMPORTANT!!!)
<subNod1>someOtherTextValue</subNode1>
</node2>
</root>
Dicti...
Dear ladies and sirs.
I have an XElement instance and I wish to write to a stream using XmlWriter class. Why? Well, one of the configuration settings defines whether to use binary Xml or not. Based on this setting a suitable XmlWriter instance is created - either by XmlWriter.Create(stream) or XmlDictionaryWriter.CreateBinaryWriter(stre...
I'm writing an xml file to be consumed by excel.
excel wants this:
<Cell><Data ss:Type="Number">25</Data></Cell>
I'm writing this...
<Cell>
<Data ss:Type="Number">25</Data>
</Cell>
I get that EXCEL is picky, but since I'm using XElelments, how do i control the formatting of the output?
here is my code to write a cell.
foreach...
I have an ASMX webservice that returns XElement - (not an .svc WCF service)
When consuming the service in Silverlight the client that is generated uses XElement as I want.
However in C# .NET 3.5 WCF 'Service Reference' it generates this property using XmlDocument.
In C# .NET 4 WCF 'Service Reference' it also generates this property us...
Hi guys, I'm building a WCF web service which returns a composite object that looks similar to the following:
[DataContract]
public class WebServiceReturn
{
...
[DataMember]
public XmlElement Results { get; set; }
...
}
When I return a WebServiceReturn object with the following code, e...