FAQ Database Discussion Community


Unable to remove empty xmlns attribute from XElement using c#

c#,xml,linq-to-xml,xml-namespaces,xmlns
Before posting this question I have tried all other solution on stack, but with no success. I am unable to remove empty xmlns attribute from XElement using C#, I have tried the following Codes. XElement.Attributes().Where(a => a.IsNamespaceDeclaration).Remove(); Another one which postted here foreach (var attr in objXMl.Descendants().Attributes()) { var elem...

Query for all elements of a specific name with XMLDocument

c#,xml,linq,linq-to-xml,xml-namespaces
I have the following XML name Sample.xml which I am trying to query accountNo with XDocument: <Request xmlns="http://CompanyName.AppName.version1"> <Person> <AccountNo>83838</AccountNo> <FirstName>Tom</FirstName> <LastName>Jackson</LastName> </Person> <Person> <AccountNo>789875</AccountNo> <FirstName>Chris</FirstName> <LastName>Smith</LastName> </Person> Using below code in C# i am able to fetch Account no of first person XDocument xmlDoc...

Extract data from xml in c# getting NullReference

c#,xml,linq-to-xml
I am currently making my first steps in extracting data from an XML i get, where the following link provides the response I get: http://maps.google.com/maps/api/geocode/xml?address=AT,%20Wien Now I try to get the latitude and logitude of the first element: string serviceUri = string.Format("http://maps.google.com/maps/api/geocode/xml?address=AT,", location); XmlDocument doc = new XmlDocument(); XDocument X...

XDocument XDeclaration not appearing in ToString result

c#,.net,xml,linq-to-xml
I am trying to form an XML document which I will be using to send as over HTTPS to an API, however I have noticed that even though I have added an XDeclaration element to my XML the XDeclaration does not appear in the string that I return using xmlDoc.ToString()...

Creating XDocument based on existing XML file

c#,winforms,linq-to-xml
I'm trying to create XDocument based on existing XML file and use it with TreeView. I want to group contacts by the Group element. XML file structure - <Contacts> <Contact> <First_Name>Ren</First_Name> <Last_Name>Fuji</Last_Name> <Group>Test</Group> <Home_Number>Unavailable</Home_Number> <Mobile_Number>Unavailable</Mobile_Number> <Image></Image> </Contact> <Contacts> Here is the method which creates XDocument object - static XDocument groupXDoc...

Building XML using XDocument in C# [closed]

c#,xml,linq-to-xml
The goal is to build the below XML in C#, writing it out via StreamWriter and pass it as part of HTTP Request. <WEB_INTEGRATION_REQUEST> <HTTP_HEADER_INFORMATION> <DEFINED_HEADERS> <HTTP_DEFINED_REQUEST_HEADER> <ItemNameType>RequesteDate</ItemNameType> <ItemValue>{TIME VALUE}</ItemValue> </HTTP_DEFINED_REQUEST_HEADER> <HTTP_DEFINED_REQUEST_HEADER> <ItemNameType>AuthorizationValue</ItemNameType> <ItemValue>{EncryptedCredentials}</ItemValue>...

Accessing nested elements while iterating an XML LINQ query?

c#,xml,linq,linq-to-xml
With this XML data: <item> <placemarks> <placemark> <uid>{EA5FA2B2-78CB-4FAA-9F17-EBB361410499}</uid> </placemark> </placemarks> <links> <link> <title>Book Online</title> <link>https://blah</link> </link> <link> <title>Call to Book</title> <link>tel:1-866-555-5555</link> </link> </links> </item> I'm trying to create Hotel objects w/ various attributes from the XML. Everything works fine until I hit nested...

Error when building an XDocument

c#,xml,linq,xpath,linq-to-xml
Using the following example xml containing one duplicate: <Persons> <Person> <PersonID>7506</PersonID> <Forename>K</Forename> <Surname>Seddon</Surname> <ChosenName /> <MiddleName /> <LegalSurname /> <Gender>Male</Gender> </Person> <Person> <PersonID>6914</PersonID> <Forename>Clark</Forename> <Surname>Kent</Surname> <ChosenName>Clark</ChosenName> <MiddleName />...

Cant go deeper than root, LINQ to (Funds)XML, C#

c#,linq-to-xml,xelement
I'm working with a specific FundsXML-Schema trying to get all Assetss of a specific XML-File to iterate through. Short example of xml-file: <?xml version="1.0" encoding="utf-8"?> <FundsXML xmlns="http://www.fundsxml.org/XMLSchema/3.0.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="3.0.5" xsi:schemaLocation="http://www.fundsxml.org/XMLSchema/3.0.5 FundsXML3.0.5.xsd"> <Date>2015-02-27</Date> ... <AssetMasterData> <Asset> <SecurityCodes> <ISIN>XXXXXXXXXXXX</ISIN>...

Create ZipArchive from XML with base64 encoded content

c#,asp.net,zip,linq-to-xml
I am creating an XML file on the fly. One of it's nodes contains a ZIP file encoded as a BASE64 string. I then create another ZIP file. I add this XML file and a few other JPEG files. I output the file to the browser. I am unable to...

Serialized Class instance not returning XML

c#,asp.net,.net,linq-to-xml
I have a method to return as instance of a class to XML. Unfortunately, no XML is being returned. Below is an example of trying to convert a simple Country Class to XML: Country Class public class Country : XmlMethods<Country> { public readonly int Id; public readonly string Code; public...

Linq to XML Is Returning Null

c#,xml,linq,linq-to-xml
<LastLayout2 CompactMode="1" Schema="37"> <CommandBars> ... <CommandBar Class="CXTPToolBar" BarID="200" Flags="63" Style="4194304" Title="Standard" MRUWidth="32767"> <Controls> <Control Class="CXTPControlButton" Id="5864" Parameter="3000" /> <Control Class="CXTPControlButton" Id="5866" Parameter="3001" /> <Control Class="CXTPControlButton" Id="5868" Parameter="3002" /> <Control Class="CXTPControlButton" Id="24322" BeginGroup="1" Parameter="3003" /> <Control...

Creating “texttext” content inside a tag in an XDocument file via LINQ to XML

c#,html,xml,reflection,linq-to-xml
I am using the XDocument class and LINQ to XML to create some simple HTML output, and I stumbled over a problem that I can't seem to solve. Perhaps it isn't even possible at all when using XML. I have a POCO with a lot of properties, and some of...

How check file XML

xml,xsd,xml-parsing,xmlhttprequest,linq-to-xml
I have xml file. I think file is not correct.I check file in validator. I get link: http://validator.w3.org. I get 3 warinngs but document is good. My question is that file correct.Do I must add DOCTYPE. Can you help me.I am green in XML. Can you give me tutorial, books,...

I need to make linq to run depending on the value is floating point or not

c#,xml,linq,linq-to-xml
I am using XDocument to make search on large XML files. When a user seeks a numeric value I get the value as decimal, I do not differentiate between integers and floating point values. I know that assuming that the input from XML as a decimal is faulty but can...

Retrieve a node value from xml

c#,linq,linq-to-xml
I want to get the value of a node <abc> from xmldata column. XML data looks like: <data id="d4E8121C9636942F18AC77F3EECD13ABA"> <d id="pDF21A1781B684FAD8D476BF14F78D52D"> <abc>ABC</abc> </d> </data> Here is the code: using (var exampleSource = new ExampleDataSource()) { var xmlData = exampleSource.queue .Where(a => a.QueueID == queueID) .Select(a => a.XMLData) .FirstOrDefault(); var messages...

Failing to delete node based on attribute

c#,xml,linq-to-xml
I'm trying to delete a XML Node based on one of the attributes of the node. The XML structure looks like this: <root> <outer> <Series InstanceUID="" TimeStamp="" Delete="true"> <Image InstanceUID="" File="" TimeStamp=""/> <Image InstanceUID="" File="" TimeStamp=""/> </Series> <Series InstanceUID="" TimeStamp="" Delete="true"> <Image InstanceUID="" File="" TimeStamp=""/> <Image InstanceUID="" File="" TimeStamp=""/> </Series>...

Get XElement by value of its attribute

vb.net,linq-to-xml,xelement
I've got the following XML: <rootNode> ... some stuff <ReportCellRef> <dang n="DVCompany" h="0" u="0" o="0" fmt="0"> ... some stuff </dang> </ReportCellRef> </rootNode> And I want get the <dang ...> ... </dang> node as XElement, so I can replace it with another node, provided I have the value of the n...

Remove all nodes in a specified namespace from XML

c#,xml,linq-to-xml
I have an XML document that contains some content in a namespace. Here is an example: <?xml version="1.0" encoding="UTF-8"?> <root xmlns:test="urn:my-test-urn"> <Item name="Item one"> <test:AlternativeName>Another name</test:AlternativeName> <Price test:Currency="GBP">124.00</Price> </Item> </root> I want to remove all of the content that is within the test namespace - not just remove the namespace...

Accessing XElement with specific value

c#,xml,linq,linq-to-xml,xelement
I am trying to save my battleship game to XML and so far it has gone pretty good. What I'm saving in the XML file is player names, coordinates for ships and misses. The ID attribute for the ships is to know which ship coordinates makes a whole ship. Next...

How can I pass individual values from a string[] to the XDocument.Load Stream?

c#,arrays,linq,xpath,linq-to-xml
I have this code: namespace ReadXMLfromFile { class Program { static void Main(string[] args) { string path = args[0]; Console.WriteLine("Looking in Directory: " + path); Console.WriteLine("Files in Directory:"); string[] files = Directory.GetFiles(path, "*.xml"); foreach (string file in files) { Console.WriteLine(Path.GetFileName(file)); } XDocument doc = XDocument.Load(???????); var spec = doc.XPathSelectElement("project/triggers/hudson.triggers.TimerTrigger/spec").Value; //Write...

Insert data from C# to XML with using Linq issue?

c#,xml,linq-to-xml
I am building a C# application. I want to insert the following XML data to XML. <?xml version="1.0" encoding="utf-8"?> <Employees> <Employee ID="1"> <Name>Numeri</Name> </Employee> <Employee ID="2"> <Name>Ismail</Name> </Employee> <Employee ID="3"> <Name>jemu</Name> </Employee> </Employees> Previously I have tried an XML that has not attribute value, But now I want to insert...

XML against XSD from file with MinOccurance using XDocument

xml,xsd,linq-to-xml
i use some xsdMarkup string xsdMarkup = @"<?xml version='1.0' encoding='utf-8'?> <xs:schema attributeFormDefault='unqualified' elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'> <xs:element name='catalog'> <xs:complexType> <xs:sequence> <xs:element maxOccurs='unbounded' name='book'> <xs:complexType> <xs:sequence> <xs:element name='authors'> <xs:complexType> <xs:sequence> <xs:element maxOccurs='unbounded' name='author'...

I want to display the first node XML attribute on form?

c#,xml,linq,linq-to-xml
I have this XML file: <tree> <grand name ="tom" id="1" sex="m" status="d" child="2" father="" /> <grand name="adam" id="11" sex="m" status="d" child="1" father="1" /> <grand name="john" id="111" sex="m" status="d" child="1" father="11" /> <grand name="pierre" id="1111" sex="m" status="d" child="3" father="111" /> <grand name="jan" id="11111" sex="f" status="d" child="" father="1111" /> <grand name="marc" id="11112"...

Get XML node value when previous node value conditions are true (without looping)

xml,vb.net,linq-to-xml
Sample XML - <?xml version="1.0"?> <Root> <PhoneType dataType="string"> <Value>CELL</Value> </PhoneType> <PhonePrimaryYn dataType="string"> <Value>Y</Value> </PhonePrimaryYn> <PhoneNumber dataType="string"> <Value>555-555-5554</Value> </PhoneNumber> <PhonePrimaryYn dataType="string"> <Value>Y</Value> </PhonePrimaryYn> <PhoneType dataType="string"> <Value>HOME</Value> </PhoneType>...

Selecting a child node having specific value

c#,xml,linq,linq-to-xml
I want to check that if the "< city>" node 'having a specific value (say Pathankot )' already exist in the xml file under the a particular "< user Id="any"> having a specific Id", before inserting a new city node into the xml. < users> < user Id="4/28/2015 11:29:44 PM">...

Query for unique id with XDocument

c#,xml,linq,linq-to-xml,xml-namespaces
I have the following XML name Sample.xml which I am trying to query uniqueID with XDocument: <Request> <Person xmlns="http://CompanyName.AppName.version1" uniqueID="3221"> <AccountNo>83838</AccountNo> <FirstName>Tom</FirstName> <LastName>Jackson</LastName> </Person> <Person xmlns="http://CompanyName.AppName.version1" uniqueID="21132"> <AccountNo>789875</AccountNo> <FirstName>Chris</FirstName> <LastName>Smith</LastName>...

c# XDocument issue

c#,xml,linq-to-xml
I am quite new to xml-parsing. Following very basic tutorials I try to parse the following xml returned by a CalDav server: <?xml version="1.0" encoding="utf-8" ?> <multistatus xmlns="DAV:"> <response> <href>/caldav.php/icalendar.ics</href> <propstat> <prop> <getetag>"xxxx-xxxx-xxxx"</getetag> </prop> <status>HTTP/1.1 200 OK</status> </propstat> </response> <sync-token>data:,20</sync-token> </multistatus> Now I want to find my "response"...

Iterating an XML document using XDocument only return 1 descendant

c#,xml,linq,c#-4.0,linq-to-xml
I am struggling with the XDocument class. I have an XML document which has "produkter", and then a long list of children (1000+). However, when I call xdoc.Descendants("produkter").Count(), the length is only 1. My code: public void Transform() { var path = HttpContext.Current.Server.MapPath("~/Content/Feeds/produkter-partnerid13389-Bianco.dk.xml"); XDocument xdoc = XDocument.Load(path); foreach (XElement xe...

how to reoder the xml [closed]

c#,xml,linq,linq-to-xml
Workign on xml reorder My XML is as follows: <Subjects> <Subject> <Name></Name> <Height></Height> <Addresss> <Address> <City>AB</City> </Address> </Addresses> </Subject> <Subject> <Name></Name> <Height></Height> <Addresss> <Address> <City>CD</City> </Address> </Addresses> </Subject> </Subjects> Now i want to creat XML as follows by adding address reference to the subject <Order>...

Specifiying a default namespace for XDocument gives empty value

c#,xml,linq-to-xml
When I try to parse XDocument from text, I can get the default namespace like this: var xmlDocument1 = XDocument.Parse("<root xmlns='http://somenamespace'></root>"); var xmlNamespace1 = xmlDocument1.Root.GetDefaultNamespace().NamespaceName; // somenamespace However, if I try to create XDocument manually, I'm getting an empty value: var xmlRoot2 = new XElement(XName.Get("root", "http://somenamespace")); var xmlDocument2 = new...

Parse XML using LINQ to XML?

c#,xml,linq-to-xml
I try to use Linq to parse a XML in C#. this is the XML I am parsing: <Credit> <LoanApp> <LoanAppRq PaymentCall="True" Personal="True" Type="Finance"> <Applicant> <Personal> <Individuals> <Individual Type="Applicant"> <GivenName> <FirstName>test</FirstName> <LastName>tester</LastName> </GivenName> <ContactInfo> <Address Type="Current"> <StreetNumber>6</StreetNumber> <StreetName>alton AVE</StreetName>...

Get value of an Xml attribute using Linq to Xml

c#,xml,linq,linq-to-xml
I have an XML like this: <?xml version="1.0" encoding="utf-8"?> <Projects> <Project> <Name>Projekt0</Name> <Information> <Version>1.0</Version> <Info>test-project</Info> <CreateDate>25.02.2015</CreateDate> </Information> <Files ID="1" path="D:\Data\ID1"> <file>one_file</file> <file>another_file</file> </Files> <Files ID="2" path="D:\Data\ID2"> <file>someFile.txt</file> </Files>...

Way to populate class object in single LINQ XML query?

c#,xml,linq,linq-to-xml
Given the following XML snippet, is there a way to both query and populate a class object in one LINQ statement? It's confusing because of the need to select using attribute values. <data> <array> <item key="0"> <map> <item key="mrid">53030</item> <item key="mrtitle">GeneralFeedback</item> </map> </item> </array> </data> Class: public class Incident {...

Linq to XML is Reducing File Size

c#,xml,linq,linq-to-xml
I have an XML file that begins at 1,030KB. After I run my code, which is adding an element to a section of the xml file, the file reduces to a size of 580kb. I think this might be a reason why a secondary application reading this file, cannot read...

Linq to Xml : highlighting respective child nodes upon selecting parent node

c#,xml,linq-to-xml
I'm working on a LINQ to XML query where if I select the branch(parent node), only child nodes which is specific to that branch should highlight. I am developing an ASP.NET tool, in that I need to read an XML file, which reads parent node first, based on user selection,...

Xml gets corrupted each time I append a node

c#,xml,linq-to-xml,windows-phone-8.1
I have an Xml file as: <?xml version="1.0"?> <hashnotes> <hashtags> <hashtag>#birthday</hashtag> <hashtag>#meeting</hashtag> <hashtag>#anniversary</hashtag> </hashtags> <lastid>0</lastid> <Settings> <Font>Arial</Font> <HashtagColor>red</HashtagColor> <passwordset>0</passwordset> <password></password> </Settings> </hashnotes> I then call a function to add a node in the xml, The function is : public...

Not getting desired elements from XDocument

c#,linq-to-xml
I am doing a company name search from a website. The website returns the response as XML. I am trying to convert the XML to a custom List. I have converted the XML response into a XDocument but the node values that I am trying to get are not retrieved....

Read only root-element from XML

c#,xml,linq-to-xml,xmldocument
I have a very large xml-file (let's say it has about 300000 elements). In my part of the application I only have to know if the name of the root-element is ApplicationLog and if there is an attribute called LogId in the root-element. To read the XML I use: XDocument...

Creating object to represent XML data using C#

c#,linq-to-xml
below is the XML code. <Shops> <Shop> <Location>INDIA</Location> <Id>123</Id> <ShopLists> <ShopList> <Area>500sqft</Area> <Name>Home Decor</Name> <LicenseNo>Ab123</LicenseNo> </ShopList> <ShopList> <Area>1000sqft</Area> <LicenseNo>Ab123</LicenseNo> </ShopList> </ShopLists> </Shop> </Shops> Creating an object with C# using Linq is finding challenging here as one of the data is missing in...

Remove the Parent Node based on Child condition

c#,xml,linq,linq-to-xml
I need help here to remove the xml node based on some condition Here is my xml <result> <product> <auto> <report> <auto> <admin></admin> <report> <search> <subjects> <subject> <name> <first>John</first> <last>D</last> </name> </subject> </subjects> </search> </report> </auto> </report> </auto> <auto> <report> <auto> <admin></admin> <report> <search>...

Select attribute value of parent element in Linq to XML of C#

c#,linq-to-xml
I am using Linq to XML of C#. I am trying to find out the parent attribute value using Xpath. This Xpath works when I run it against XML but is somehow giving an error in Linq to XML. The error is: Expression must evaluate to a node-set. and here...

How I can collect similar xml tag to groups with Xml.Linq in c#?

c#,xml,linq,linq-to-xml,xelement
I have a xml file with this style <all_elements> <elements> <element attribute="7" /> <element attribute="1" /> <element attribute="6" /> </elements> <elements> <element attribute="2" /> <element attribute="8" /> </elements> . . . </all_elements> I want calculate average of each elements seprate with c# Xml.Linq, for exapmle: average1= 4.66 average2= 5.00 I...

how to import node in XML

c#,linq-to-xml,xmldocument
Parent XML <order> <class/> <account> <saving/> </account> </order> I want to import node to parent xml Node: <data> <address/> </data> After importing, final xml as <order> <class/> <account> <saving/> </account> <data> <address/> </data> </order> Please help me here I tried as below: XmlDocument doc = new XmlDocument(); doc.LoadXml(childXML.InnerXml); mlNode newNodeDataset...

LINQ request for getting the furthest xml child node with an attribute

c#,xml,linq,xml-parsing,linq-to-xml
I have an xml file that defines item/location categories, and their id's like follow: <?xml version="1.0" encoding="UTF-8"?> <Eve_App> <Item_Types> <Ore> <Arkonor> <Arkonor ID="22"/> <Compressed_Arkonor ID="28367"/> <Compressed_Crimson_Arkonor ID="28385"/> <Compressed_Prime_Arkonor ID="28387"/> <Crimson_Arkonor ID="17425"/> <Prime_Arkonor ID="17426"/> </Arkonor> <Bistot> <Bistot ID="1223"/> <Compressed_Bistot ID="28388"/>...

Extracting Data from XML to List<>

c#,xml,linq,list,linq-to-xml
I have this XML file: <?xml version="1.0" encoding="utf-8" ?> <Record> <File name="1.mot"> <Line address="040004" data="0720" /> <Line address="040037" data="31" /> <Line address="04004C" data="55AA55AA" /> </File> <File name="2.mot"> <Line address="00008242" data="06" /> <Line address="00008025" data="AFC8" /> <Line address="00009302" data="476F6C64" /> </File> </Record> What I want to do is to extract the...

Could not read web.sitemap

c#,linq-to-xml,web.sitemap
I have been trying reading web.sitemap using LINQ but could not make it. Following is my web.sitemap <?xml version="1.0" encoding="utf-8"?> <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"> <siteMapNode url="" title="Root"> <siteMapNode url="" title="Manage"> <siteMapNode url="~/Users.aspx" title="Users" name="10001"/> <siteMapNode url="~/Targets.aspx" title="Target" name="10002" /> <siteMapNode url="~/Cases.aspx" title="Case" name="10003" /> <siteMapNode...

LINQ to XML to find a specific category in xml

c#,xml,linq,linq-to-xml
I have the following xml: <table name="transactions"> <row> <col name="id">1</col> <col name="amount">2673.9</col> <col name="created_date">2014-10-19</col> <col name="display_date">2014-04-22</col> <col name="cat_id">13</col> <col name="note">Initial Balance</col> //other col tags </row> <row> ... </row> </table> I need to find all rows with a specific cat_id. How would the LINQ query look like? I tried IEnumerable<XElement> rows...

Iterating through a list of XML Elements

c#,linq-to-xml
I would like to place a follow-up to a previously asked question but apparently I'm not allowed to continue this in the same thread. In my previous question (Iterating through a list of elements inside an element with a specific index) I was looking for the value of all of...

Linq to XML data structure

c#,xml,linq,linq-to-xml
This is my XML: <home> <contents> <row> <content> <idContent>1</idContent> <title>title1</title> </content> <content> <idContent>2</idContent> <title>title2</title> </content> </row> <row> <content> <idContent>3</idContent> <title>title3</title> </content> <content> <idContent>4</idContent> <title>title4</title> </content> </row>...

Visual Basic XML Literals Embedded Expressions - Can I do simple math?

xml,vb.net,visual-studio,linq-to-xml,xml-literals
I'm getting stumped by what I hope is a simple problem. I'm trying to embed a simple formula incrementing a variable to act as a "line number" for an XML document. Writing literal XML in visual basic. Here's what the code looks like: <%= From d In orderData Select <ItemOut...

multi Elements to multi rows

c#,xml,linq,linq-to-xml
I made some try with XML Reader, Xpath... and know linq But wont find a way to solve these things. I have to extract the information, for each Order into one row, in this row should be the Information of the first elements and the Items and the orders as...

XDocument Save Removing Node Prefixes

c#,xml,linq-to-xml
I have an XML document (homegrown) that has a structure like the following: <?xml version="1.0" encoding="utf-8"?> <wf:wf version="1.0a" xmlns:wf="http://example.com/workflow" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://example.com/workflow"> <wf:assemblies /> <wf:dataDefinitions /> <wf:processes /> <wf:workflows> <wf:workflow id="g08615517-cdfd-4091-a053-217a965f7118"> <wf:arguments /> <wf:variables>...

How to add Namespace and Declaration to the existing XML

c#,c#-4.0,linq-to-xml
how to add Namespace and Declaration to the existing xml. My XML <Order> <child1></child1> </Order> Expected <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <Order xmlns="http://a.com/a"> <child1></child> </Order> ...

Grabbing correct node based on attribute with multiple nodes using LINQ to XML

c#,xml,linq-to-xml
I've been having some trouble writing queries in LINQ to grab the data i need from an XML file. The XML file set up looks like this <Study id =""> <Multi> <filepath id =""></filepath> <filepath id ="display"></filepath> <combined></combined> </Multi> </Study> <Study id =""> <Multi> <filepath id =""></filepath> <filepath id ="display"></filepath>...

How to get difference between xdocument1 and xdocument2

c#,xml,.net-3.5,linq-to-xml,xdoc
I want to get difference between xdocument1 and xdocument2. on xdocument1: <prices> <price> <productid>P001</productid> <price>1000</price> <effectivedate>2015-05-11T00:00:00+7</effectivedate> </price> </prices> and on xdocument2: <prices> <price> <productid>P001</productid> <price>870</price> <effectivedate>2015-05-11T00:00:00+7</effectivedate> </price> </prices> How can I get the difference between them, if...

Using Linq to get XML data from database

c#,xml,linq,linq-to-xml
I'm struggling to get the values of a single xml node using Linq. Here is my XML. <?xml version="1.0" encoding="utf-8"?> <record> <AddressLine1>abcd street</AddressLine1> <AddressLine2>xyz AVE</AddressLine2> <AddressCity>Illinois</AddressCity> <AddressState>Chicago</AddressState> <AddressZip>23434</AddressZip> </record> And here is my c# code XElement xmlDoc = XElement.Parse(varQ.Content); //When I debug I find that xmlDoc contains the XML. So...

Inserting XML to XMLDocument

c#,.net,linq,linq-to-xml
My XML is as follows: <School> <ClassA> <Students> <Student> <Name>AB</Name> <Score>90</Score> </Student> </Students> </ClassA> </School> Loading the XML into XmlDocument XmlDocument xmlRequest = new XmlDocument(); xmlRequest.LoadXml(myXML); Now reading the array of records in LINQ and creating the XML dynamically var xmlSubjects = new XElement("subjects", from c in arrySubjects select new...

Multithreading with XDocument.Load

xml,vb.net,multithreading,linq-to-xml
I am trying to make my code work in a separate thread but can't make it work. I have tried following several different multi-threading examples from the internet using delegates, but nothing fixed my problem. I need to load data from an XML file via a URL and then show...

XElement Replacement when Child Elements and Value Exist

c#,xml,linq,replace,linq-to-xml
I have some Xml that I am trying to change the name of the XElement on. The XElement contains both child elements and a value similar to this <parent> Hi I am a value <a href="link">link</a> </parent> I tried using the method suggested here but i can only copy either...

LINQ to XML query Where() function not returning anything

c#,linq,parsing,xml-parsing,linq-to-xml
I have an XML file I would like to parse using LINQ in order to get all nodes containing the attribute ID. With this ID, the node's name, and it's grandparent's name, I would like to create an new object (of type EveItem) in the LINQ query. Here is a...

How to get to specific node and retrieve data

c#,linq-to-xml
Heres my XML <metadata created="2015-02-24T17:50:40.188Z" xmlns="http://example.com" xmlns:ext="http://example.com"> <customer-group-list count="10"> <customer-group id="790174c22752" type="Corporate"> <title>Mr</title> <primary-type>Corporate</primary-type> <customer-credit> <name-credit> <customer id="3d57f91ecf5e"> <name>Michael Jackson</name> <sort-name>Jackson, Michael</sort-name> <alias-list> <alias sort-name="JACKSON...

How to delete specific nodes from an XElement?

c#,xml,linq-to-xml
I have created a XElement with node which has XML as below. I want to remove all the "Rule" nodes if they contain "conditions" node. I create a for loop as below but it does not delete my nodes foreach (XElement xx in xRelation.Elements()) { if (xx.Element("Conditions") != null) {...

How to access element in XML files with attribute values?

c#,linq-to-xml
This is my XML file <colleges> <college college_name="DYPSOE"> <departments> <department department_name="Computer" id="10"> <![CDATA[I NEED TO CHANGE THIS COMMENT!]]> </department> <department department_name="Machanical" id="20"> <![CDATA[I NEED TO CHANGE THIS COMMENT!]]> </department> </departments> </college> <college college_name="DYPSOET"> <departments> <department department_name="Computer" id="10"> <![CDATA[I NEED TO CHANGE THIS COMMENT!]]>...

Insert XML to XML Document at specified tag

c#-4.0,linq-to-xml
I am working on XML where I want to insert below XML tag into parent xml: <Subject></Subject> Parent XML <School> <ClassB></ClassB> <ClassA> <Students> </Students> </ClassA> </School> want the final out put as <School> <ClassB></ClassB> <ClassA> <Subject></Subject> <Students> </Students> </ClassA> </School> Tried by below code: XmlDocument xmlRequest = new XmlDocument(); xmlRequest.LoadXml(parentXML);...

XElement.Add with variables

vb.net,linq,linq-to-xml
I have a short question for you: Is there a way to use variables when adding or creating a new XElement node? I'm doing it the way described in this MSDN article. Here's my code: Root.<svg:g>.First().Add(<text x="[email protected]" y="[email protected]" contenteditable="true">AktZiffernfolge</text>) However, this just creates some static text. [email protected], [email protected] and AktZiffernfolge...

Read XML to dictionary

c#,xml,linq-to-xml
I know this question have been asked multiple times, but I have not manage to solve my problem despite trying several suggestions from other similar questions. Now I ask instead, in hope to get an answer. I have this XMl file: <?xml version="1.0" encoding="utf-8"?> <WebCommands> <WebCommand> <FullCommand>@ 05c9fe42-8d89-401d-a9a5-2d82af58e16f This is...