linq-to-xml

How to generate the below XML format in Linq XML.

Below are my table structures; using those tables I want to create XML file. CREATE TABLE [dbo].[Security_Module_Menu]( [Client_Company_ID] [smallint] NOT NULL, [Module_ID] [tinyint] NOT NULL,Module_ID,Menu_ID,Reference_Menu_ID [Menu_ID] [int] NOT NULL, [Reference_Menu_ID] [int] NULL, [Menu_Name] [nvarchar](50) NULL,...

How to dynamically retrive the all the possible attributes (variable attributes) values of one of the xml node ?

I am using the following XML structure <SERVERS> <SERVER NAME="A1" ID="1"></SERVER> <SERVER NAME="A2"></SERVER> <SERVER NAME="A3" ID="3" Parent="XYZ"></SERVER> <SERVER NAME="A4" ID="4"></SERVER> <SERVER NAME="A5" Parent="abc" value="10"></SERVER> <SERVER NAME="A6"></SERVER> </SERVERS> I am accessing this xml file by using LINQ to XML ...

How to parse XML?

This is the response I'll be getting: <?xml version="1.0" encoding="utf-8"?> <rsp stat="ok"> <image_hash>cxmHM</image_hash> <delete_hash>NNy6VNpiAA</delete_hash> <original_image>http://imgur.com/cxmHM.png&lt;/original_image&gt; <large_thumbnail>http://imgur.com/cxmHMl.png&lt;/large_thumbnail&gt; <...

LINQ to XML problem with SharePoint Web Services

I am using SharePoint Web Services to get some list items out of SharePoint for a project i am working on. I am using using LINQ to XML to parse the resulting XML to be put into a datasheet. The problem i am running into is when trying to parse an item that isn't required in SharePoint... var fields = from item in results.Descendants...

selecting an element in xml using linq extension mehtods

Hi, I am little new to linq and was wondering how i can select the application in the following xml based on the application name using Extension Methods (not using the query expression) <applicationlist> <application> <name>test1</name> <ele1>852</ele1 <ele2>http://localhost/test1&lt;/ele2&gt; </application> <application>...

Add documents using c#

I am trying to add document to the index using c# (xml) but I am always getting error 400 (Bad request). Any ideas what I am doing wrong? Code: private static string GetXml() { XDocument document = new XDocument( new XDeclaration("1.0", "UTF-8", "yes"), new XElement("add", new XEl...

How to loading XML files from a file

my xml is bellow: <Demo> <ClientCompanyId CompanyId="1"> <MyMenu> <module Text="Basic Settings" ModID="Mod1" ModuleID="1" MenuType="0" Perm="False"> <menu Text="Forms" MID="1-1" ParentID="Mod1" MenuDescription="Mod" ModuleID="1" MenuType="0" Perm="False"> <Leaf Text="LookUp" MID="1-3" ParentID="1" MenuDescription="" ModuleID="1" MenuTyp...

How do I find a XML node by path in Linq-to-XML

If I get the path to a specific node as a string can I somehow easily find said node by using Linq/Method of the XElement ( or XDocument ). There are so many different types of XML objects it would also be nice if as a added bonus you could point me to a guide on why/how to use different types. EDIT: Ok after being pointed towards XPat...

How to AspxMenu fill from xml file

On my page I have two AspxMenu.Click on Master Menu correspondent value will show on Child menu XML syntax: <Demo> <ClientCompanyId CompanyId="1"> <MyMenu> <module Text="Basic Settings" ModID="Mod1" ModuleID="1" MenuType="0" Perm="False"> <menu Text="Forms" MID="1-1" ParentID="Mod1" MenuDescription="Mod" ModuleID="1" MenuType="0" Perm...

What does the "...parameterless constructors and initializers are supported..." error mean?

I'm getting this error: Only parameterless constructors and initializers are supported in LINQ to Entities. When trying to run this code (found this code here and made test database to play around with): XElement xml = new XElement("contacts", from c in db.Contacts orderby c.ContactId ...

Linq2XML Query problem (not accepting ':' in names)

Hi, i have a xml file which has following elements: <rs:data> <z:row entry='*[email protected]' type='1'/> i need to access them by using Linq2Xml. My problem is that i get an exception which tells me that the ':' sign can not be used in Names. my Linq2Xml Query is: var rowQuery = from Mail in whiteMails.Descendants("xml").Descendants("rs:d...

Sorting all the elements in a XDocument

Hi, I have a XDocument where I'd like to sort all of the elements alphabetically. Here's a simplified version of the structure: <Config> <Server> <Id>svr1</Id> <Routing> <RoutingNodeName>route1</RoutingNodeName> <Subscription> <Id>1</Id> </Subscription> <RoutingParameters id="Routing...

LINQ to XML in a WCF Service

I am using VS 2008. I have to create a wcf service and inside the service i have to do some basic operations on a xml file using LINQ to XML. I have to host the service in IIS 7.0 and consume it. As part of the LINQ to XML I have to do the following tasks : find all the questions in all the Enquiry that answers are no modify the quest...

Query with Linq to xml

Hi Guys, I am Fairly new to Linq and I am trying to write a simple query to return the error messages within my xml file. <?xml version="1.0" encoding="utf-8"?> <Error xmlns="urn:xxxxx"> The following errors were detected: <Message>Internal Error</Message></Error> The following works and returns the error mes...

How to retrive the name of the attribute dynamically without specifying the name of the attribute ?

I am developing asp.net mobile application. I am using LINQ to XML to query XML file. I am using the following query to retrieve the name & value of the query dynamically as follows var TotalManifolds = from MF in FieldRoot.Element("FIELD-DEFINITION").Element("MANIFOLDS").Elements("MANIFOLD") join SLT in FieldRoot.E...

How to write a single LINQ to XML query to iterate through all the child elements & all the attributes of the child elements ?

I am developing asp.net mobile application. I am using XML as a database. I am querying on the XML to access the required elements & attributes by using LINQ to XML in .net. I have the follwing part in my XML file. <VALVES> <VALVE NAME="PWV"> <DISPLAY-NAME> Production Master Valve </DISPLAY-NAME> <COMMANDS...

How to query the child elements of a particular parent element

I am developing asp.net mobile application. I am using the XML as a database. I am using the following part of the XML file to query the data by using the LINQ to XML. <USER-INTERFACE-DEFINITION> <MIMICS> <MIMIC ID="1" NAME="Home"> <SECTIONS> <SECTION ID ="1" NAME="System Health" CONTROL-TYPE="Button"> ...

Hosting WCF service in IIS

I am trying to host the service in IIS but I get Page Not found error. Here is what I did to host in IIS Created a WCF Service application (BillingService) I have two classes called IBillSrv.cs (as Base) and BillSrvc.cs Added a new WCFService website (BillSrvcSite) to the solution and added a reference to the above mentioned (BillingS...

How to pass parameters to LINQ to XML query by using lambda expression ?

I am new to LINQ to XML in .net(C#, asp.net). I want to know more about Lambda expressions. I am using Lambada expression with the following query. count = FieldRoot.Element("USER").Element("MM") .Descendants("MMMS") .Where(a => a.Attribute("ID").Value == MID) .SelectMany(b => b.Descendants("ABC")).Co...

XLINQ - Is it possible to have conditionals within a query?

In trying to teach myself ASP.NET and OO design in general, I decided to make a simple web-based game. It's a rudimentary role-playing game, where the player can create a character of a certain profession. These professions give the character certain kinds of attacks, and some of these abilities have status effects (poison on enemies, ...