XML Feed - How To Get Collection Of Elements (Assets) Via LINQ
Mar 9, 2011
I have the following XML which I load via XDocument.Load(uri) or XElement.Load(uri). I am having trouble getting a collection of <asset> elements via LINQ.
Here is a snippet of the XML I'm trying to query:
<assetCollection xmlns="tag:aisle7.net,2009:/api/1.0">
<title>All Assets</title>
<description>Collection containing all assets in the system</description>
<resourcePath>/us/assets/~all</resourcePath>
[Code] .....
I am attempting to consume my Zenfolio RSS feed so that i can display the images in the feed. How can i access the url value of the media:thumbnail and media:content elements in my RSS feed? I have googled high and low and not found an answer regarding how to access the url value. There was a similiar unanswered SO post.
Examples of the elements: <media:thumbnail url="http://riderdesign.net/img/s11/v35/p449020235-2.jpg" width="400"
I have a collection (a Dictionary, actually) of strings as the key and strings as the value. The value strings are filenames. I wish to find which elements contain a certain filename as the value, returning the Key so that I can modify the Value (change the filename).[code]....
I've got the following ADO.NET Entity Framework Entity Data Model:I want to find all the Policyholders with both a Service of a given Id and also a Keyword of a given Status.
This LINQ Does Not Work:
Dim ServicesId As Integer = ... Dim KeywordStatus As Integer = ... Dim FoundPolicyholders = From p As Policyholder In db.PolicyholderSet.Include("Keywords").Include("Services") _ Where p.Services.Id = ServicesId _ And p.Keywords.Status = KeywordStatus _ Select p
The Where clause cannot search the p.Services and p.Keywords EntityCollections in that way.
I'm converting a library from C# to VB.net which so far hasn't been too difficult. One class though implements IEnumerable and IEnumerator and contains a block of code like this:
public class MyClassCollection { // Assume all other necessary code is in place
i have found some info on this but nothing i can use... im using vb.net to automate excel before i print the excel worksheet i need to change the printers setting to use the manual feed tray instead of the auto feed
Say a collection grow. Once it's size reach 10k, I want to get rid the first 9k. How to do so?Oh ya I could use removeRange.Is there another function that will output say, the last 1k of the element, say if I do not want to remove anything? Something like tail or something.
Public Class Store Public Overridable Property Areas As List(Of Area) End Class Public Class Area
[code]....
What's the quickest way to get a total count of shelves for a store? I.e. for a store I get the total count of areas by using Areas.Count Or will I need to loop through each area and tally the count of shelves?
how to search XML trees with LINQ using VB.net. I've found some very helpful posts for C#, but none for VB.net?How would I use LINQ to XML to get the value from example XML Getting a set of elements using linq How to get elements value with Linq To XML I want to get the inputlocation for the process where name = "MyProcess1" Based on the example links above, I have been trying code like this:
Dim inputLocation As String = xdocument.Descendants("Configurations").Descendants("process").First(Function(c) c.Element("name").Value = "MyProcess1").Element("inputLocation").Value
But the code is not returning any values. here is the xml
I have this XML <?xml version="1.0" encoding="utf-8"?> <root> <xsd:schema id="root" xmlns="" xmlns:xsd="[URL]" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:import namespace="[URL]" /> <xsd:element name="root" msdata:IsDataSet="true"> [Code] .....
And I also have this method, where I take two files and take some values from them, and then I merge all the values into an object in the second query: Public Shared Function RetrieveTranslation(ByVal filefrom As String, ByVal fileto As String) As List(Of clsTranslation) Dim valuefrom = (From l In XElement.Load(fileto).Elements("data") Select l.Element("value").Value).FirstOrDefault [Code] .....
So, the problem is that when I run the code, there is an "Sequence contains no elements" error in the first query(valuefrom). I debugged and it says that there is nothing in the query, but I don't understand why? I'm curious to know if it is well done to do something like I did, create an object from two queries, putting the first value in the second query.
Is there any way to use a LINQ to XML to query an XML document like the one below to create new (anonymous or strongly typed) objects from the child elements of a descendant? Here is my XML document:
I have got an xml document which looks something like this.
<Root> <Info> </Info> <Info>
[Code]...
How can i write a linqToXML query so that it returns me an IEnumerable containing each child element, in this case all five child elements of , so that i could iterate over them. The order of child elements is not definite, neither is number of times the may appear.
I'm working on a .NET application (VB 2008) that gets all of its data from a web-based Django application.I'm using Linq-to-XML and Linq-to-objects in the app.One API call is giving me XML data in the following format that I am loading into an XDocument.
I am trying to figure something out. I have an application in which I am adding the ability to consume a feed. I have no problem with the feed itself, but my problem is how can I mark certain items as 'read'? The only thing I can thing of is to read the feed into a database. In this database, I add a column for 'read' which I update when the user has read the article. Then each time I retrieve the feed, I compare the feed to the database and only load new items into the database.
However, only the first phone number (Office) displays in the listbox. The phoneinfo collection has both <phone> elements, but the For Each statement doesn't seem to iterate thru.
I have a Customer object which has a collection of ContactNumbers. Is it possible with LINQ to get a list of Customers where one of the contact numbers = '123'?
Public Class Customer Public Overridable Property ContactNumbers As List(Of ContactNumber) End Class
Basically I have added a lot of images to my project and I wonder how to refer to them in my code.At the moment I am linking to them by the full windows path, but that isn't going to make things very portable.Could someone give me a short example on how I use these image files internally within the project if that makes sense.
On my view there is a datatable holding a collection of ServerRow and 4 textboxes (Hostname, OS, Location, Zone). When the user types into any of the 4 boxes I want to immediately filter this list. I have this code setup and ready to go that on the set method of each textbox property I call the filter method.
Now onto the problem: if I have 4 criteria that means I have 2 to the power of 4 different scenarios. What I would like to do is write a linq statement with all of these scenarios dealt with such that if any of the properties are NullOrEmpty they will not be used in the Where clause and on the flip side if there is a value the corresponding field will be searched with a Contains.