linq-to-xml

Reading specific XML parameter

陌路散爱 提交于 2020-01-06 17:28:38
问题 I'm currently working on a project in which a xml file must be read for program settings. The XML looks like this: <?xml version="1.0" encoding="utf-8"?> <!-- Settings for Modul1 --> <root> <Program-Config> <Parameter>Name</Parameter> <Value>John</Value> </Program-Config> <Program-Config> <Parameter>Device</Parameter> <Value>TV</Value> </Program-Config> . . . </root> This structure is also used to fill a datagridview like this: Parameter | Value __________|______ Name | John Device | TV This

Finding Matching Nodes in two XML files using linqpad and linq to xml is finding 0 results

我们两清 提交于 2020-01-06 08:23:48
问题 I have two XML files with the same schema/structure but with different data. I am trying to use Linqpad (Linq to XML) to find the differences between the two files. Here is my code... XElement FILE1 = XElement.Load (@"..\FILE1.XML"); XElement FILE2 = XElement.Load (@"..\FILE2.XML"); var orders = from file1 in FILE1.Descendants("Players").Elements("Player") select new { name=new { firstName=file1.Element("FirstName"), lastName=file1.Element("LastName") } }; var orders2 = from file2 in FILE2

HTML Agility Pack Conversion to XML <script> corruption

99封情书 提交于 2020-01-06 06:32:33
问题 I've got an HTML file with a <script> in it: <html> <script type="application/custom+xml"> <my><xml><goes><here/></goes></xml></my> </script> </html> I parse it with HTML Agility Pack and then convert it to XML. HtmlDocument html; html.OptionOutputAsXml = true; html.Save(stream); ... XDocument xml = XDocument.Load(stream); I then want to use LINQ-to-XML to look at the contents of the script tag which should contain my XML as CDATA. But HTML Agility Pack messes it up somehow and I end up with

Parse Nested XML with xDocument

梦想与她 提交于 2020-01-06 03:36:07
问题 I have an XML format of this structure (the real world example is horrendously long and complicated, but this should illustrate it): <document> <post> <author>Bill Smith</author> <subject>Test Article</subject> <dates> <uploaded>some date</uploaded> <published>some date</published> </dates> </post> <post> <author>Bill Smith</author> <subject>Test Article</subject> <dates> <uploaded>some date</uploaded> <published>some date</published> </dates> </post> </document> I have wrote a simple query

Different behaviour between “new XmlTextReader” and “XmlReader.Create”

帅比萌擦擦* 提交于 2020-01-06 03:00:45
问题 Given the following source code: using System; using System.IO; using System.Xml; using System.Xml.Schema; namespace TheXMLGames { class Program { static void Main(string[] args) { XmlReaderSettings settings = new XmlReaderSettings { Async = false, ConformanceLevel = ConformanceLevel.Fragment, DtdProcessing = DtdProcessing.Ignore, ValidationFlags = XmlSchemaValidationFlags.None, ValidationType = ValidationType.None, XmlResolver = null, }; string head = File.ReadAllText("sample.xml"); Stream

How to separate img tags in description of xml (RSS FEED)

大城市里の小女人 提交于 2020-01-06 02:58:06
问题 I am unable to retrieve images from RSS feeds i.e., in description. I am using the following code to retrieve information. var rssFeed = from el in doc.Elements("rss").Elements("channel").Elements("item") orderby datetime(el.Element("pubDate").Value) descending select new { Title = el.Element("title").Value, Link = el.Element("link").Value, Description =el.Element("description").Value, PubDate = datetime(el.Element("pubDate").Value), }; When Description is being displayed, both text and image

Complex nested XML Parsing in C#

大城市里の小女人 提交于 2020-01-05 10:31:52
问题 <ndActivityLog repositoryId="AA-AAAA1AAA" repositoryName="Company Name" startDate="2013-07-05" endDate="2013-07-06"> <activity date="2013-07-05T06:42:35" name="open" host="00.00.00.00"> <user id="joebloggs@email.com" name="Joe Bloggs" memberType="I" /> <storageObject docId="0000-0000-0000" name="Opinion" size="356864" fileExtension="doc"> <cabinet name="Client and Matters">NG-5MIYABBV</cabinet> <DocumentType>Legal Document</DocumentType> <Author>Joe Bloggs</Author> <Matter>1001</Matter>

Complex nested XML Parsing in C#

此生再无相见时 提交于 2020-01-05 10:30:12
问题 <ndActivityLog repositoryId="AA-AAAA1AAA" repositoryName="Company Name" startDate="2013-07-05" endDate="2013-07-06"> <activity date="2013-07-05T06:42:35" name="open" host="00.00.00.00"> <user id="joebloggs@email.com" name="Joe Bloggs" memberType="I" /> <storageObject docId="0000-0000-0000" name="Opinion" size="356864" fileExtension="doc"> <cabinet name="Client and Matters">NG-5MIYABBV</cabinet> <DocumentType>Legal Document</DocumentType> <Author>Joe Bloggs</Author> <Matter>1001</Matter>

XPathEvaluate behave differently in other environments

流过昼夜 提交于 2020-01-05 09:06:24
问题 I am working on a game in unity and want to parse an XML file in a unity script, my file starts with the line <map version="1.0" orientation="orthogonal" width="16" height="12" tilewidth="64" tileheight="64"> and I want to get the map width attribute, my code is : var mapWidth = ((IEnumerable)tiledMapXmlRoot.XPathEvaluate("/@width")).Cast<XAttribute>().Select(a => Int32.Parse(a.Value)).First(); which is working right when I test it in visual studio, but fail when it runs in a unity script,

How to use LINQ to XML when XML parent and child nodes have the same name

て烟熏妆下的殇ゞ 提交于 2020-01-05 07:23:07
问题 I am trying to extract some SQL data to XML from a Microsoft Dynamics environment, I am currently using LINQ To XML in C# to read and write to my XML files. One piece of data I need is from a view called SECURITYSUBROLE. Looking at the structure of this view shows that there is a column also named SECURITYSUBROLE. My normal method of extraction has given me this XML. <SECURITYSUBROLE> <SECURITYROLE>886301</SECURITYROLE> <SECURITYSUBROLE>886317</SECURITYSUBROLE> <VALIDFROM>1900-01-01T00:00:00