I have some xml similar to this:
<?xml version="1.0" encoding="utf-8" ?>
<data>
<resources>
<resource key="Title">Alpha</resource>
<resource key="ImageName">Small.png</resource>
<resource key="Desc">blah</resource>
</resources>
</data>
using linq-xml how can i assign each resource here as a key value pair w...
Hi, I'm having an issue getting a LINQ query to work. I have this XML:
<devices>
<device id ="2142" name="data-switch-01">
<interface id ="2148" description ="Po1"/>
</device>
<device id ="2302" name="data-switch-02">
<interface id ="2354" description ="Po1"/>
<interface id ="2348" description ="Gi0/44" />
</...
Hi All
I have the following class
public class CountrySpecificPIIEntity
{
public string Country { get; set; }
public string CreditCardType { get; set; }
public String Api { get; set; }
public List<String> FilterList { get; set; }
}
I am trying to use a linq to XMl query to create a list of instances of type CountrySpecificPIIEn...
I got a XML document with a lot of data divided into category->subcategory. Like this:
<?xml version="1.0" encoding="utf-8" ?>
<data>
<car>
<transmission>
<option value="1" text="Manual" />
<option value="2" text="Automatic" />
</transmission>
<milage>
<option value="2" tex...
The following code returns the error from the For Each loop. I have similar code that does not return the error.
'DisplayTitle' is not a member of 'Sting'
Dim evXML As XDocument = XDocument.Load(Server.MapPath("~/App_Data/event.xml"))
Dim sbEventDetail As New StringBuilder()
Dim summary = _
From sum In evXML.<root>.Elements() _
Select...
I am trying to read in a simple XML file, however when I run the SQL it always returns Ennumeration Yeilded no results.
Not sure what I am going wrong.
XDocument xmlInfo = XDocument.Parse(xmlContent);
XNamespace ns = xmlInfo.Root.Name.Namespace;
XNamespace ns = xmlBuilderInfo.Root.Name.Namespace;
var Info = from XMLtagin xmlInfo.D...
I have an XML structure that is 4 deep:
<?xml version="1.0" encoding="utf-8"?>
<EmailRuleList xmlns:xsd="EmailRules.xsd">
<TargetPST name="Tech Communities">
<Parse emailAsList="true" useJustDomain="false" fromAddress="false" toAddress="true">
<EmailRule address="@aspadvice.com" folder="Lists, ASP" saveAttachments="false" />...
I have some code below that is throwing an exception in integration environments but not in my unit tests. Basically I'm sorting some XML elements (linq-2-sql XElement) by an attribute value. All the nodes have the attribute defined.
IEnumerable<XElement> elements = ...; // elementes are of the form<recipe name="something">
elements....
What is the XPath (in C# API to XDocument.XPathSelectElements(xpath, nsman) if it matters) to query all MyNodes from this document?
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<MyNode xmlns="lcmp" attr="true">
<subnode />
</MyNode>
</configuration>
I tried /configuration/MyNode which is wrong because it ignores the...
I am having xml with following structure
<ruleDefinition appId="3" customerId = "acf">
<node alias="element1" id="1" name="department">
<node alias="element2" id="101" name="mike" />
<node alias="element2" id="102" name="ricky" />
<node alias="element2" id="103" name="jim" />
</node>
</ruleDefinition>
...
I'm using Linq-to-XML to do a simple "is this user registered" check (no security here, just making a list of registered users for a desktop app). How do I handle the result from a query like this:
var people = from person in currentDoc.Descendants("Users")
where (string)person.Element("User") == searchBox.Text
...
Hello..
I am trying to get all of the "video" elements and their attributes from an XML file that looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<videos>
<video title="video1" path="videos\video1.wma"/>
<video title="video2" path="videos\video2.wma"/>
<video title="video3" path="videos\video3.wma"/>
</videos>
The foll...
I have XML string that has parent nodes "Committee" and inside that another child node "Committee" is there. When I am using "from committee in xDocument.DescendantsAndSelf("Committee")" it is reading childnode also, but I don't want to read child nodes, I just want to read Parent nodes only.
<Committee>
<Position>STAFF</Position>
...
I have the following code and got myself confused:
I have a query that returns a set of records that have been identified as duplicates and I then want to create a XElement for each one. This should be done in one query I think but I'm now lost.
var f = (from x in MyDocument.Descendants("RECORD")
where ite...
Hi ,
We want the query result should be assigned with two results based on some condition like following:
var vAudioData = (from xAudioinfo in xResponse.Descendants(ns + "DIDL-Lite").Elements(ns + "item")
if((xAudioinfo.Element(upnp + "artist")!=null)
{
select new RMSMedia
{
strAudioTitle = ((string)xAudioinfo.Element(dc + "title")).T...
Say I've a class (model) called Instance with Properties DatbaseHostname, AccessManagerHostname, DatabaseUsername and DatabasePassword
public class Instance
{
private string _DatabaseHostname;
public string DatabaseHostname
{
get { return _DatabaseHostname; }
set { _DatabaseHostname = value; }
}
priv...
I want to create a Xml file that looks something like this:
<Root xmlns:ns1="name1" xmlns:ns2="name2">
<ns1:element1 />
<ns1:element2 />
<ns2:element3 />
</Root>
How can I accomplish this using XAttribute, XElement, XNamespace, and XDocument where the namespaces are dynamically added.
...
I have an xml file that contains its element like
<ab:test>Str</ab:test>
When i am trying to access it using the code
XElement tempElement = doc.Descendants(XName.Get("ab:test")).FirstOrDefault();
Its giving me error
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlExc...
(First post, please be gentle!)
I am just learning about LINQ to XML in all its glory and frailty, trying to hack it to do what I want to do:
Given an XML file like this -
<list>
<!-- random data, keys, values, etc.-->
<key>FIRST_WANTED_KEY</key>
<value>FIRST_WANTED_VALUE</value>
<key>SECOND_WANTED_KEY</key>
<value>SECOND_W...
I have several columns that I'd like to search against. My code might not get passed anything for a given column to search against. So for the example below either lastname or firstname might be an empty string. Whenever I search against a column with an empty string it messes up the query. I've fixed the problem by checking to see if...