Given the following XML, I would like to return all eventtitles where the eventtype id = 23. My current query only looks at the first eventtype, so returns the wrong result.
<event>
<eventtitle>Garrison Keillor</eventtitle>
<eventtypes>
<eventtype id="24"/>
<eventtype id="23"/>
</eventtypes>
</e...
<Party id="Party_1">
<PartyTypeCode tc="1">Person</PartyTypeCode>
<FullName>John Doe</FullName>
<GovtID>123456789</GovtID>
<GovtIDTC tc="1">Social Security Number US</GovtIDTC>
<ResidenceState tc="35">New Jersey</ResidenceState>
<Person>
<Firs...
Hi, i have got a standing answer in this thread.
http://stackoverflow.com/questions/2396203/get-the-count-of-elements-where-candidate-has-won
But i am failing to get the percentage, what am i doing wrong. I have the code below.
var s4 = from can in allCandidates
let noDists= ((from d in root.Elements("Provinces")
...
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...
I have the following XML Document (that can be redesigned if necessary) that stores records and errors.
<MYROOT>
<RECORDS>
<RECORD>
<DATETIME>11/03/2010 14:12:41</DATETIME>
<DOCUMENTID>1</DOCUMENTID>
</RECORD>
<RECORD>
<DATETIME>11/03/2010 14:12:44</DATETIME>
<DOCUMENTID>2</DOCUMENTID>
</RECOR...
I want to query a xml file.
I read this http://weblogs.asp.net/scottgu/archive/2007/08/07/using-linq-to-xml-and-how-to-build-a-custom-rss-feed-reader-with-it.aspx ,
But in my case i don't know the names of elements and attributes of the file.
So i could i do ?
Thanks
...
I am loading an XML document into an XDocument object, doing a query and then returning the data through a web service as an XmlDocument object.
The code below works fine, but it just seems a bit smelly. Is there a cleaner way to take the results of the query and convert back to an XDocument or XmlDocument?
XDocument xd = X...
Hi,
I'm adding an element to existing XML doc with the following code:
Dim theXMLSource As String = Server.MapPath("~/Demo/") & "LabDemo.xml"
Dim nodeElement As XElement
Dim attrAndValue As XElement = _
<LabService>
<ServiceType>
<%= txtServiceType.Text.Trim %>
</ServiceT...
I have a Dictionary<int, MyClass>
It contains 100,000 items
10,000 items value is populated whilst 90,000 are null.
I have this code:
var nullitems = MyInfoCollection.Where(x => x.Value == null).ToList();
nullitems.ForEach(x => LogMissedSequenceError(x.Key + 1));
private void LogMissedSequenceError(long SequenceNumber)
{
...
Hi,
I'm editing XML element with the following XML:
<?xml version="1.0" encoding="utf-8"?>
<!--Test XML with LINQ to XML-->
<LabSerivceInfo>
<LabService>
<ServiceType>Copy</ServiceType>
<Price>1</Price>
</LabService>
<LabService>
<ServiceType>PrintBlackAndWhite</ServiceType>
<Price>2</Price>
</LabService>...
Hi,
I'm trying to update an element in the XML document below:
Here's the code:
Dim xmldoc As XDocument = XDocument.Load(theXMLSource1)
Dim ql As XElement = (From ls In xmldoc.Elements("LabService") _
Where CType(ls.Element("ServiceType"), String).Equals("Scan") _
Select ls.Element("Price")).Fir...
Hi all,
I have the following class
public class CountrySpecificPIIEntity
{
public string Country { get; set; }
public string CreditCardType { get; set; }
public String Language { get; set; }
public List<String> PIIData { get; set; }
}
I have the following XML that I want to query using Linq-to-xml and shape in...
I have a XDocument that looks like this:
XDocument outputDocument = new XDocument(
new XElement("Document",
new XElement("Stuff")
)
);
That when I call
outputDocument.ToString()
Outputs to this:
<Document>
<Stuff />
</Document>
But I want it to look like this:
...
I'm in the process of moving from ADO.NET to Linq. The application is a directory search program to look people up. The users are allowed to type the search criteria into a single textbox. They can separate each term with a space, or wrap a phrase in quotes such as "park place" to indicate that it is one term.
Behind the scenes the d...
HI
I have an example document that looks like
<ItemEntry>
<PurchaseDate>2010-03-18T20:36:32.81108+13:00</PurchaseDate>
<StoreGUID>0a0324ad-5f99-486a-a2d0-870bc6991e9f</StoreGUID>
<ExpiryDate />
<CardID>111111</CardID>
<PurchaseAmount>0</PurchaseAmount>
<RedeemedAmount />
<EntryType>1</EntryType>
<RedeemedDate />
<SalesAssistantID>0</Sa...
I've got some XML I'm trying to import with c#, which looks something like this:
<root>
<run>
<name = "bob"/>
<date = "1958"/>
</run>
<run>
<name = "alice"/>
<date = "1969"/>
</run>
</root>
I load my xml using
XElement xDoc=XElement.Load(filename);
What I want to do is have a class for "run", under which I can sto...
Hi currently I have a nested XMl , having the following Structure :
<?xml version="1.0" encoding="utf-8" ?>
<Response>
<Result>
<item id="something" />
<price na="something" />
<?xml version="1.0" encoding="UTF-8" ?>
<DIDL-Lite xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/" xmlns:dc="http://pur...
I'm reading in a Kml file, changing the placemarks' names, and saving it again.
var KmlFile = XDocument.Load("C:\\Inetpub\\wwwroot\\GeotagService\\Kml\\Photographs.kml");
XNamespace KmlNamespace = "http://www.opengis.net/kml/2.2";
// find the Placemarks in the Photos folder
IEnumerable<XElement> Placemarks = KmlFile.Element(KmlNamespa...
My current LINQ query and example XML are below. What I'd like to do is select the primary email address from the email-addresses element into the User.Email property.
The type element under the
email-address element is set to primary when this is true.
There may
be more than one element under the
email-addresses but only one will be...