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
ADVERTISEMENT
May 9, 2012
I've managed to get my CSV file opened and the individual elements of each line read into an array. I've also managed to count and list the number of elements in the first row (i.e. the column headers).
[code]...
listOfNewFileRecords.Add(currentRow)' ADD EACH RECORD TO THE LIST AS THE FILE IS BEING READ Now the next stage is to access various cells within the whole opened file, so that I can condition/modify the text.So does 'ListOfNewFileRecords' have a way/method of accessing a particular element, in each record of the 'List'? I've tried using the intellisense, but can't make enough sense out of it to get anything to work.
View 11 Replies
Jul 3, 2010
I'm trying to write some of my own linear algebra methods, and I'd like them to work independent of the number of dimensions of the array. However, there doesn't seem to be any generic method, that I can see, for looking up a particular element in an array of arbitrary size. I mean I could write code to find the rank and then use (), (,), (,,), (,,,), etc, but that seems rather cumbersome.
View 4 Replies
Aug 9, 2011
I have the following function,
Dim results() As Object = Me.Invoke("webdirect", New Object() {Company, LocationCode, CustomerNumber, OrderNumber, OrderRef, OrderDate, WebLines})
o_Company = CType(results(1),System.Nullable(Of Integer))
o_LocationCode = CType(results(2),String)
o_CustomerNumber = CType(results(3),String)
[Code] .....
So the return type of this function is a string, but I would like to get it back to its original form so I can access the individual sections i.e. o_LocationCode,o_CustomerNumber, etc how can I do that ?
Entire functions looks like this
Public Function webdirect(<System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal Company As System.Nullable(Of Integer), <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal LocationCode As String, <System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal CustomerNumber As String,
[Code] .....
Called like this
Dim returnArray As String
returnArray = client.webdirect(10, "123", "123", "123", "147", "2011-11-1", webLinesArray, 10, "", "", "", "", "", webRespArray)
No errors on run time but the string seems to be just blank, thats why i was wondering how I convert the string back to the array so I can access the individual elements.
View 1 Replies
Feb 25, 2011
Here's my json:
{"d":{"key1":"value1",
"key2":"value2"}}
Is there any way of accessing the keys and values (in javascript) in this array without knowing what the keys are?
The reason my json is structured like this is that the webmethod that I'm calling via jquery is returning a dictionary. If it's impossible to work with the above, what do I need to change about the way I'm returning the data?
Here's an outline of my webmethod:
<WebMethod()> _
Public Function Foo(ByVal Input As String) As Dictionary(Of String, String)
Dim Results As New Dictionary(Of String, String)
[Code]....
View 2 Replies
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
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
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
Aug 17, 2009
I'm having trouble adding child elements to the below
<securities>
<security id="040104JC6">
[code]....
View 2 Replies
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
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
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
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
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
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
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
Mar 31, 2012
This application uses a Microsoft Access database named Books to keep track of the books in a store. The database has one table named tblBooks. The table has five fields. The BookNumber, Price, and QuantityInStock fields are numeric. The Title and Author fields contain text. This application should allow a user to enter an author's name ( or part of a name ) and then display only the titles of books written by the author. Displaying the information in a DataGridView control; however, don't allow the user to add, delete, modify, or save records. I need to allow the user to specify the records he or she wants to select while the application is running. Also, i need to Add a text box and a button to the BindingNavigator control. The user will use the text box to specify the records he wants to select. The user will use the button to tell the computer to display the selected records. I also want to display the total value of the books in the store. I am not getting the BindingNavigator control in the component tray in my program I've included. Also I am working on the code for the display button but I need some tips. I am trying to complete this program and only expect guidance.[code]
View 12 Replies
Sep 17, 2010
I created a method and pass the element type, id, and any inner text that instantiates a new html element. The last statement: Me.Controls.Add(element) adds it to the end of the page, but I would like it to be inserted in a specific position (between 2 divs within a form). What I am describing is very similar to this post on SO here, although it was for javascript.
View 1 Replies
Jan 2, 2010
Dim Document = XDocument.Load(FileName)
Dim findElement = Document.Elements("GradeProfile")
[code]....
View 4 Replies
Jun 30, 2010
Basically in visual basic 6 I could access word tables in existing templates with the code owordactivedoc.tables(1).select() where owordactivedoc refers to the active word document and tables(1) refers to the first table in the template.Trying the same code in VB 2003 just leads to errors. Secondly how do I access bookmarks or alternatively word variables.Furthermore how do one deploy web.services. For example the current program I am building is for another computer. Simply copying the web service to Inetpubwwwroot dont work because it is not picked up by the Internet Information Services program. I have to create the web service in vb2003 on the other computer change msconfig manually. Copy and paste the existing service vb file in the created folder replacing the empty vb file.
View 3 Replies
Jul 14, 2011
given this function:
Public Function Search(ByVal StartIndex As Integer, _
ByVal MaxResults As Integer, _
ByVal AccountNumber As String, _
ByVal LastName As String, _
[Code]....
instead of what I expected:
Select count(*) from remitline where lastname = "smith"
What am I doing wrong building up the where clause? I'm using Castle ActiveRecord 2.1
View 1 Replies
Aug 6, 2009
if there is that much of a performance gain in running a LINQ stored procedure versus a LINQ query?
View 1 Replies
Apr 20, 2011
I have a listbox on my xaml form that I bound to a List(Of MyType) property. I populated this list like so:
Dim fields As List(Of CheckableFields) = New List(Of CheckableFields)
Using context As ITIPEntities = New ITIPEntities()
Try[code]....
Now I'm at the point where the user selects the fields they want included in a report and I need to iterate over the required fields. This is my linq query:
For Each checkedField In _requiredFields
If checkedField.IsChecked Then
If checkedField.FieldData IsNot Nothing AndAlso checkedField.FieldData.Trim IsNot String.Empty Then[code].....
View 1 Replies
Sep 10, 2009
Example-I have a person class
Public Class Person
Private _fname As String
Public Property Fname() As String
[Code]...
View 2 Replies
Mar 31, 2011
Forgive my ignorance on this.I have this LINQ Query:Dim ngBikersDataContext As New CarBikeWalkDataContext
bikersList = (From c In ngBikersDataContext.Reg_Bikers _
Order By c.L_Name _
Select New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
[Code]...
with the error "Overload resolution failed because no accesible 'Select' accepts this number of arguments."
Over the "NEW" I get an error " ')'expected."
View 1 Replies
Jan 27, 2011
We are doing a query against an in-memory collection of LINQ data objects. The wrinkle is that we are ordering by a column in a related table whose records have not necessarily been loaded yet (deferred loading:)
Dim oPkgProducts = _
From b In oBillPkg.BillProducts _
Where b.Successful.GetValueOrDefault(Common.X_INDETERMINATE) = _
[code]....
View 1 Replies
Feb 28, 2012
The pattern I'm trying to avoid is checking if a string (normally a control's text value) is null/empty, and if it is, comparing it using Contains to a field in my data. Obviously the field isn't hard-coded into my extension, neither is the object type.What I've got works perfectly in Linq to Objects, but I get the generic run-time error "LINQ to Entities does not recognize the method 'System.String Invoke(GenericQueryHelper.Customer)' method, and this method cannot be translated into a store expression." when using an entity framework model.
Here's what I have:
<System.Runtime.CompilerServices.Extension()>
Public Function CompareAndFilter(Of T)(source As System.Linq.IQueryable(Of T), expressionField As System.Linq.Expressions.Expression(Of System.Func(Of T, String)), compareTo As String)
[code]....
I want my usage to look something like this:
Dim results = repository.Customers.CompareAndFilter(Function(c) c.FirstName, searchText)
I do need to get this running against a SQL database really, as it is filtering results, so I don't want to be doing that in memory.
View 2 Replies
Jun 27, 2012
How can I convert this code LINQ to SQL in C # LINQ to SQL in Vb.net
[Code]...
View 2 Replies
Aug 31, 2011
How do I add ROW_NUMBER to a LINQ query or Entity? How can I convert this solution to VB.NET?
[Code]...
I'm having trouble porting that last line. I have been unable to locate a VB.NET example. I'm actually not looking for any paging functionality like the example provides, just good old-fashioned Row_Number(Order By X) row index.
View 1 Replies
Oct 21, 2009
How can I convert an object of type System.Data.Linq.DataQuery to System.Linq.IQueryable?I'm working with Visual Basic/Silverlight, and the source code of my query is as follows:
Public Function Get_Cli_Pag() As IQueryable(Of V_Cliente_Pagare)
Dim Qry = From P In Me.Context.Pagares Join C In Me.Context.Codigos On C.Codigo
[code]....
View 1 Replies