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] .....

View 2 Replies


ADVERTISEMENT

VB2008 - Linq XML Feed, Separating Data?

Sep 10, 2010

This is a follow on from my previous thread in which .[URL]

in brief i have the following XML string which contains many hundered users, i have shortened it for posting

<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">
<users>

[Code]....

View 5 Replies

Access Url Attr Of Media:thumbnail And Media:content Elements In RSS Feed?

Nov 21, 2011

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"

[code]....

View 1 Replies

Get Elements From Collection Containing Value?

Dec 5, 2009

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]....

View 4 Replies

.net - Search The Collection Of A Collection In LINQ Where Clause?

Apr 15, 2009

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.

[Code]...

View 1 Replies

Search The Collection Of A Collection In LINQ Where Clause?

Apr 15, 2011

search the collection of a collection in my LINQ Where clause?

View 11 Replies

Individual Elements In A Collection?

Jan 7, 2010

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

[code].....

View 2 Replies

C# - Selecting Distinct Elements From A Collection?

Dec 14, 2011

I need to select distinct highways from a roads collection.

I suppose I could use LINQ for this.

I have (stub code)

Dim roads As List(Of Roads) = myRegion.Roads
Dim highways As New List(Of Highway)
For Each road In roads

[Code]....

View 5 Replies

Change The Printers Setting To Use The Manual Feed Tray Instead Of The Auto Feed

Oct 14, 2010

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

View 2 Replies

Pick Last 1000 Elements From A Generic Collection?

Mar 1, 2011

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.

View 7 Replies

.NET LINQ - Count Of Collection Within Collection?

Apr 14, 2011

Take the following scenario:

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?

View 2 Replies

C# - Getting A Set Of Elements Using Linq?

Mar 26, 2010

I have the following piece of XML:

<xml>
<ObsCont xCampo="field1">
<xTexto>example1</xTexto>

[Code]....

How do I (using linq) get for example what is inside the xTexto tag that has as parent the ObsCont with the xCampo attribute "field2" ?

View 3 Replies

Accessing XML Elements With LINQ Using .net (not C#)?

Nov 29, 2011

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

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Configurations>
<process>

[code]....

View 1 Replies

Linq Get Elements For The First N Groups?

Mar 16, 2012

I would like to get the first N groups elements with Linq of a ObservableCollection, an example trying to get the first 2 groups:

Data example:

GROUP1 item1
GROUP1 item2
GROUP1 item3
GROUP2 item1

[code]....

View 5 Replies

LINQ To XML - Sequence Contains No Elements

May 25, 2011

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.

View 1 Replies

Add Child Elements To Existing Xml - Linq?

Aug 17, 2009

I'm having trouble adding child elements to the below
<securities>
<security id="040104JC6">

[code]....

View 2 Replies

VS 2008 LINQ When Some Elements 'could' Be Missing?

Jan 27, 2010

some of the xelements within the query were calling for tags that didn't exist in the original xml, heres a simple example of what i mean.

element = _
<xml>
<object>
<string>someString</string>

[code]....

So how do i change the querry so that it wont produce a null error if the tags asked for are not present.

View 7 Replies

VS 2010 LINQ Sub-elements And Joining

Mar 30, 2012

I'm really struggling with this. I have two XML files. The first one has items, and then sub elements for properties:

[Code]...

View 3 Replies

[2008] LINQ - Xml Elements Into A Datagridview?

Oct 20, 2009

I've become undone when trying to convert xml linq query result to a datagridview (see code below), needing some pointers,.

Dim doc As XDocument
doc = XDocument.Load("C: empxmltest.xml")
Dim query = From c In doc.<quotefile>.<quote> _

[code].....

View 3 Replies

Creating Objects From Child Elements Using LINQ To XML

Feb 1, 2011

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:

[Code]...

View 2 Replies

Linq To Xml Query Returning A List Of All Child Elements?

Mar 8, 2010

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.

View 1 Replies

Replace Xml Content In Conditionally Selected Elements Using Linq (VB 2008)?

Mar 22, 2009

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.

[Code]...

View 1 Replies

Feed Reader - Compare The Feed To The Database And Only Load New Items Into The Database

Nov 8, 2011

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.

View 2 Replies

LINQ To XML, Only Can Get First Item In Collection?

Sep 8, 2010

Here is an example of my xml doc:

<?xml version="1.0" encoding="utf-8"?>
<employeedata>
<employee>
<firstname>Bob</firstname>
<lastname>Anderson</lastname>

[Code]...

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.

View 8 Replies

LINQ Where Statement In Collection?

Mar 28, 2012

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

[Code].....

View 1 Replies

How To Use Project Assets

Jul 9, 2011

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.

View 12 Replies

Build A String From A Collection With Linq?

Oct 8, 2009

I'm building flat file content from collections of strings.

Example collection: A, B, C, D, E, etc.

I want to be able to output these values to a string with line feeds in one swoop with Linq if possible.[cod]e...

View 8 Replies

Get Last Instance Of Collection Controls Using Linq?

Mar 6, 2012

How to get the last instance of label control in List (of Control) using linq?

View 4 Replies

Linq Iterate A Control Collection?

Jun 29, 2009

Private Function GetWebDataGridOKButtonId() As String
Dim ctls As ControlCollection = _
WebDataGrid1.Controls(0).Controls(0).Controls

[Code]....

This is not working for me. I am trying to iterate a control collection and return one control ID.

View 2 Replies

Filtering A Collection With Linq And Multiple Criteria?

Jun 7, 2012

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.

Example

AvailableCis = New ObservableCollection(Of ServerRow)
(_CiData.Where(Function(ci) ci.OS.ToUpper
.Equals(_selectedOS.ToUpper) AndAlso
ci.HostName.ToUpper.Contains(_ciNameFilterText.ToUpper))
.OrderBy(Function(a) a.CiName))

This example shows how it works with 2 criteria and both of those criteria are set.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved