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


ADVERTISEMENT

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

Adding XElement As A Child Of An Existing XElement Linq?

Mar 6, 2012

I would like to add a XElement into an existing XElement as a child

Dim myDocument As New XDocument
myDocument.Declaration = New XDeclaration("1.0", "utf-8", "no")
myDocument.Add(New XComment("XComment"))

[Code]....

What is the best way? There will be at least one rule but there could be as many as 4 total.

View 4 Replies

Read All Elements And Child Nodes Of XML In A List Using XDocument?

Jul 6, 2011

I have to get all the Entity Source,Entity Target,Property Source and Property Target values in list respectively.[code]...

View 1 Replies

Silverlight RIA Hierarchical Model Not Returning Child Elements?

Jun 21, 2011

I ham developing a Silverlight RIA solution that needs to return a hierarchical model from the server which is declared as below.

Imports System.ComponentModel.DataAnnotations
Imports System.Collections.Generic
Imports System.Runtime.Serialization

[code].....

View 1 Replies

Wpf - Hide Dynamically Created Child Elements Of A Grid?

Aug 30, 2011

I have a grid in which I have created and added elements from the code behind.

Dim staffImgLeft As New Controls.Image()
staffImgLeft.Name = "StaffImgLeft"
mainGrid.Children.Add(staffImgLeft)

When I am attempt to remove the child elements from the grid they are not being removed.

mainGrid.Children.Remove(mainGrid.FindName("StaffImgLeft"))

There are no errors when the code runs. Can anyone advise why my code isnt working?

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

.net - Repository Pattern - Remove Child Elements From Multiple Parents

Nov 16, 2011

I have the following tables

Public Class Tag
<Key()> _
Public Property TagID As Integer

[Code].....

I implemented the repository pattern.

Now i have a list of Tags which contain the right TagReferences, but the tags may not be deleted, it's the TagReferences.

Variabels = ReferenceValue,ReferenceID
IEnumerable(Of Tag) = TagRepository.GetMany(Function(el) el.Reference = ReferenceValue And el.TagReferences.Any(Function(bl) bl.ReferencedID.Equals(ReferenceID)))

How can i remove all the TagReferences which contain the ReferenceID in one line?

View 1 Replies

Filter Parent / Child Table In Linq Query Based On Entities In Child Table?

Jul 9, 2010

I have a table (Projects) which is linked to projectVersions on projectID..projectVersions contains several columns on which I'd like to filter a returned project (and associated projectVersions) list. For example there is a "capacity" column and a "country" column. I am doing a filtered list of projects on one page and I'd like to include all projects where any one of the associated projectVersions has a capacity of 750ml and a country of "France" for example.It may be that a particular parameter is not set and so I pass a zero to indicate not to filter on that.I guess this needs some kind of subquery as when I try and do something like this: [code] it doesn't work as the "xxx" bit, being one-to-many, expects me to specify an item to get at the entities within and yet I want to query where ANY of the associated versions match one of the criteria.

View 1 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

Change Existing Form To An MDI Child?

Aug 24, 2011

I have a form already created, but now want to expand the application.I created a MDIParent, but cant seem to find how to change the existing form to an MDI child.

View 3 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

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

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

.net - How To PLINQ An Existing LINQ Query With Joins

Sep 28, 2011

I'm using LINQ to compare two DataSets with each other to create new rows and update existing. I've noticed that the complete comparison lasts ~1,5 hours and only one of the two cores is busy(Task-Manager is 50-52% CPU Usage). I assume that it could increase performance significantly.

how and what should I parallelize?

These are the original queries(reduced to the essentials):

'check for new data
Dim srcUnique = From row In src.Email_Total
Select Ticket_ID = row.ticket_id, Interaction = row.interaction, ModifiedAt = row.modified_time

[Code].....

View 1 Replies

.net - Use LINQ To Count The Number Of Combinations Existing In Two Lists?

Jun 17, 2010

I'm trying to create a LINQ query (or queries) that count the total number of occurences of a combinations of items in one list that exist in a different list. For example, take the following lists:

CartItems DiscountItems
========= =============
AAA AAA

[code]....

The result of the query operation should be 2 since I can find two combinations of AAA and BBB (from DiscountItems) within the contents of CartItems.My thinking in approaching the query is to join the lists together to shorten CartItems to only include items from DiscountItems. The solution would be to find the CartItem in the resulting query that occurs the least amount of times, thus indicating how many combinations of items exist in CartItems.When CartItems is filtered to only the items in DiscountItems, it can be visually displayed like this:

CartItems that get a discount
=============================
AAA BBB <= This combination is eligible for a discount
AAA BBB <= This combination is eligible for a discount
AAA <= Not eligible

Thus, because there are 2 combinations of the discount in the Cart, the result is 2.Here's the query I already have, but it's not working. query results in an enumeration with 100 items, far more than I expected.

Dim query = From cartItem In Cart.CartItems
Group Join discountItem
In DiscountGroup.DiscountItems

[code]....

View 2 Replies

Linq To Objects - (C#) Creating A Dictionary From An Existing List Without Looping?

Aug 31, 2011

I don't know if this is doable, maybe with Linq, but I have a List(Of MyType):

Public Class MyType
Property key As Char
Property description As String
End Class

And I want to create a Dictionary(Of Char, MyType) using the key field as the dictionary keys and the values in the List as the dictionary values, with something like:

New Dictionary(Of Char, MyType)(??)

Even if this is doable, internally it will loop through all the List items, I guess?

View 3 Replies

Use LINQ Add CHILD VALUE Always 1?

Jul 19, 2011

Use LINQ add CHILD VALUE always 1?I have the Tables [code]...

View 1 Replies

Asp.net - Enable/disable Web Elements Of A Parent Aspx Page From The Child Ascx Page?

Jul 20, 2009

I have an aspx page with three web controls: one to control the List Users page, one to control the Edit Users page, and one to control the Add User page. I have discovered a method for accessing these elements, but it seems to be limited. Here is what I have done:

Protected Sub editUser(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs)
'set selected user from gridview.

[Code].....

This works in most cases. However, I am unable to access the "enabled" attribute of these web controls. Why is this, and how might I access that attribute?

View 2 Replies

Adding Namespace Attribute To XElement - Prevent Blank/empty Namespace On Child Elements?

Mar 17, 2011

I need to read an xml document from a database record into an XDocument object in order for it to be deserialized. So that the deserialization will work, I need to apply a specific namespace to each of the level 1 elements. So XML looks a bit like this:

[Code]...

How do I prevent the blank/empty namespace being added to each child element of the element to which the required namespace has been applied?

View 1 Replies

LINQ To XML And Child Objects?

Nov 20, 2009

I am creating a tool that interfaces with an API for a CD/DVD burner. I have created several custom classes that will hold the information for the disk sets (which consist of a data path and a label file among other information. The DiskSet class has a list of Include objects. My proposed XML output would be something similar to the following:

<DiskSets>
<DiskSet>
<Name>MySet 1</Name>

[code].....

I am attempting to traverse the Includes collection (I have tried List and Binding List as I am also using this in a pair of datagridview controls) and it keeps returning Expression of type 'Object is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ provider." How can I use LINQ to pull a list of the Include objects under each DiskSet object for transformation into XML? I am hoping to keep this restricted to this one block of code if possible.

View 7 Replies

Xpath - LINQ To XML Sum Child Nodes In .NET?

Nov 1, 2011

I have the following XML from Amazon's Marketplace API. I need to sum all the values of Item/ItemPrice/Component[type='Principal']/Amount for all Items to compute an order total. Is this possible to do using LINQ to XML in VB.NET?

<?xml version="1.0"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>

[code]....

View 1 Replies

.net - Use LINQ To Find MAX Or MIN Of A Field From All Child Records

Apr 20, 2011

way to write the LINQ query. The parent class is simply a student's name and a list of test score data. The child class is a single test score datum. I want to find the worst (or best) score out of all of the TestScore values and then identify the student who had the best score.

Dim query = From s In studentList _
Where s.ScoreList.Select(Function(d) d.TestScore).Min _
= studentList.SelectMany(Function(g) g.ScoreList).Select(Function(h)

[Code].....

View 3 Replies

Aggregating Parent/child Tables Using Linq To SQL?

Sep 18, 2009

I'm having a nightmare with LINQ. I've got a table of Projects, and each project has many InvoiceHeaders. The Invoice header had a field AmountNet - the value of the invoice.

I want to retrive, for arguments sake, all of the fields from Projects, with the count of invoice headers and the sum of AmountNet. I.e. list of my projects, how many invoices I've raised and the value.

Doesn't sound hard does it.... well, I've just spent the best part of two hours charging through Google and SO to find a solution.

[Code]...

View 1 Replies

C# - LINQ - Select All In Parent-child Heirarchy

Mar 12, 2012

I was wondering if there is a neat way do to this, that DOESN'T use any kind of while loop or similar, preferably that would run against Linq to Entities as a single SQL round-trip, and also against Linq To Objects. I have an entity - Forum - that has a parent-child relationship going on. That is, a Forum may (or in the case of the top level, may not) have a ParentForum, and may have many ChildForums. A Forum then contains many Posts.

What I'm after here is a way to get all the Posts from a tree of Forums - i.e. the Forum in question, and all it's children, grandchildren etc. I don't know in advance how many sub-levels the Forum in question may have. (Note - I know this example isn't necessarily a valuble use case, but the Forum object model one is one that is familar to most people, and so serves as a generic and accessible premise rather than my actual domain model.)

View 2 Replies







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