hi i have a confusion about xml
please tell me is this valid xml or not. i want to read it using linq to xml
<registeredPeople>
<id>1</id>
<name>mohsan</name>
<id>2</id>
<name>ali</name>
<id>3</id>
<name>azhar</name>
</registeredPeople>
...
I have a linq query that is querying over IEnumberable. When I have a matching element for my where clause I would like to know the position of the element in the IEnumberable.
var result = from e in elements
where (string) e.Attribute("class") == "something"
select e.Position();
The e.Position() of course do...
When i use the results of a linq-to-xml query to populate a datagridview, i cannot edit the datagridview. i've tried setting the datagridview's readonly property to false and that doesn't help. I also added an event handler for cellBeginEdit and put a breakpoint there, but it doesn't get hit. Any idea what i'm doing wrong, or if this ...
F# newbie
I have 2 xml files in 2 folders c:\root\a\file.xml and c:\root\b\file.xml
They have identical structure
<parent>
<property name="firstName">Jane</property>
<property name="lastName">...</property>
<property name="dateOfBirth">...</property>>
</parent>
I need to chose the file which property node with name "firstNa...
XML sample (original link):
<records>
<record index="1">
<property name="Username">Sven</property>
<property name="Domain">infinity2</property>
<property name="LastLogon">12/15/2009</property>
</record>
<record index="2">
<property name="Username">Josephine</property>
<property name="Domain">infinity3</property...
Hi,
With the XElement class, its constructor clearly takes the daya type XName as its first parameter, however, if I pass in a string, it works and I don't get a compile time error.
What's going on here exactly and how can I implment this in my own code?
Thank you,
...
If a node belongs to a namespace, it's children by default belong to the same namespace. So there's no need to provide an xmlns attribute on each child, which is good.
However.
If I create two nodes like this:
Dim parent = <parent xmlns="http://my.namespace.org"/>
Dim child = <child xmlns="http://my.namespace.org">value</chil...
Hi,
I'm a completly New to Linq2XML as I code to much lines to perform simple things, and in a simple project I wanted to give it a try...
I'm with this for 2 hours and nothing I do get's it right :(
I'm really, really thinking to go back to XmlNode-code-alike
The Task:
I send a SOAP Action to an ASMX service and I get the response...
Hi all,
I have this code :
/*string theXml =
@"<Response xmlns=""http://myvalue.com""><Result xmlns:a=""http://schemas.datacontract.org/2004/07/My.Namespace"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance""><a:TheBool>true</a:TheBool><a:TheId>1</a:TheId></Result></Response>";*/
string...
I have a XML source with nodes like this (Somewhat anonymized):
<XXX>
<Code A="oa ">01</Code>
<Name A="oa ">Card</Name>
<F1 A="oa ">x</F1>
<F2 A="oa ">y</F2>
<F3 A="oa ">z</F3>
</XXX>
I load the XML-document into a XElement and query it with linq
var query = from creditcard in xml.Descend...
I'm working with an xml fragment, and finding that I'm doing the following a lot:
dim x = xe.Element("foo").Element("bar").Element("Hello").Element("World").Value
however I can't always guarantee that the xml document will contain foo or bar. Is there a nicer way to do this sort of thing without having to null check every query?
i.e....
I have a collection of MODS records that looks like this:
<modsCollection>
<mods [namespaces etc] >
<genre authority="diva" type="contentType" lang="eng">Other academic</genre>
<genre authority="diva" type="contentType" lang="swe">Övrigt vetenskapligt</genre>
<name type="personal">
<namePart type="family">Svensson</nam...
I have an XDocument object and the ToString() method returns XML without any indentation. How do I create a string from this containing indented XML?
edit: I'm asking how to create an in memory string rather than writing out to a file.
edit: Looks like I accidentally asked a trick question here... ToString() does return indented XML.
...
I'm just learning LINQ and in particular LINQ to XML, and I've written up a query that works but I'm wondering if I'm doing it a bit round-a-bout. Can the code be improved?
I have an XDocument:
<SomeDocument>
<Prop1> val1 </Prop1>
<Prop2> val2 </Prop2>
<Prop3> val3 </Prop3>
</SomeDocument>
But Prop1, Prop2, and Prop3 ma...
Hello - I am probably missing something obvious, but I am getting a 'Object reference not set to an instance of an object' null error in my Linq to xml query.
Here is a sample of the xml
<airport>
<station>
<city>Rutland</city>
<state>VT</state>
<country>US</country>
<icao>KRUT</icao>
<lat>43.52999878</lat>
<lon>-72.94999...
LINQ2Xml:
I would like to get the count of elements where candidate has won in every province. I need some help.
<Pronvice_Data>
<Pronvice>PronviceA</Pronvice>
<Registered_Voters>115852</Registered_Voters>
<Sam_Kea>100</Sam_Kea>
<Jeje>500</Jeje>
<John_Doe>400</John_Doe>
</Pronvice_Data>
<Pronvice_Data>
<Pronvice...
I had an XML Document in the format below
<Pronvice_Data>
<Pronvice>PronviceA</Pronvice>
<Registered_Voters>115852</Registered_Voters>
<Sam_Kea>100</Sam_Kea>
<Jeje>500</Jeje>
<John_Doe>400</John_Doe>
</Pronvice_Data>
<Pronvice_Data>
<Pronvice>PronviceA</Pronvice>
<Registered_Voters>25852</Registered_Voters>
...
I have the following XML LINQ query from my XDocument.
var totals = (from x in MyDocument.Descendants("TOTALS") select x).FirstOrDefault();
Once I have found my totals node I need to add some elements to that node and push that change to the XDocument.
...
I have the 2 following LINQ queries and I haven't quite got my head around LINQ so what is the difference between the 2 approaches below?
Is there a circumstance where one approach is better than another?
ChequeDocument.Descendants("ERRORS").Where(x=>(string)x.Attribute("D") == "").Count();
(from x in ChequeDocument.Descendant...
I have got an XML document which looks something like this.
<Root>
<Info>....</Info>
<Info>....</Info>
<response>....</response>
<warning>....</warning>
<Info>....</Info>
</Root>
How can i write a LINQ to XML query so that it returns me an IEnumerable containing each child element, in this case all five child elements of , so that i c...