linq-to-xml

Writing to XML using XDocument, but knowing where to write

吃可爱长大的小学妹 提交于 2019-12-21 12:23:56
问题 Hope you can help me a bit. I'm trying to write to an XML file, but am struggling to write the method which, well, writes to the XML file. This is the XML file manually written (using Notepad++ etc.): <software> <software_entry name="Adobe Acrobat X Standard" path="Applications\Acrobat\Acrobat X Standard\AcroStan.msi" type="msi" switches="/qn ALLUSERS=1" /> <software_entry name="Adobe Acrobat X Professional" path="Applications\Acrobat\Acrobat X Pro\AcroPro.msi" type="msi" switches="/qn

Advantages of XSLT or Linq to XML

江枫思渺然 提交于 2019-12-21 08:55:51
问题 What advantages are there for using either XSLT or Linq to XML for HTML parsing in C#? This is under the assumption that the html has been cleaned so it is valid xhtml. These values will eventually go into a c# object to be validated and processed. Please let me know if these are valid and if there are other things to consider. XSLT Advantages: Easy to change quickly and deploy Fairly well known XSLT Disadvantages: Not compiled, so is slower to process String manipulation can be cumbersome

Advantages of XSLT or Linq to XML

余生长醉 提交于 2019-12-21 08:55:36
问题 What advantages are there for using either XSLT or Linq to XML for HTML parsing in C#? This is under the assumption that the html has been cleaned so it is valid xhtml. These values will eventually go into a c# object to be validated and processed. Please let me know if these are valid and if there are other things to consider. XSLT Advantages: Easy to change quickly and deploy Fairly well known XSLT Disadvantages: Not compiled, so is slower to process String manipulation can be cumbersome

Linq to XML selecting a node bases on a attribute value

心已入冬 提交于 2019-12-21 07:56:11
问题 I have an xml file that returns a set of elements that are unique by a attribute value. This presents a problem, as I can not select a node by its name: <doc> <float name="score">1.2873721</float> <arr name="2_category"> <long>3021</long> </arr> <arr name="ATR_FamilyName"> <str>Some Cookbook </str> </arr> <arr name="ATR_IsFamily"> <str>0</str> </arr> <arr name="ATR_SellPrice"> <str>49.95</str> </arr> <arr name="ATR_VendorId"> <str>ABC</str> </arr> <arr name="ATR_VendorName"> <str>WROX</str> <

LINQ to XML and DataGridView

蓝咒 提交于 2019-12-21 06:43:04
问题 Hi I’m trying to use a DataGridView for the first time and with LINQ. Here’s what I’m trying to do: I want to use it (although it doesn’t have to the DataGridView ) to read and display the contents of an XML file (this bit is working code below) but I want to have an add row button on the form or in the DataGridView that takes the contents of three textboxes and and populates the contents of three columns of the new row. The new row is to be appended to the existing data. Next I would like to

LINQ to XML and DataGridView

烂漫一生 提交于 2019-12-21 06:41:41
问题 Hi I’m trying to use a DataGridView for the first time and with LINQ. Here’s what I’m trying to do: I want to use it (although it doesn’t have to the DataGridView ) to read and display the contents of an XML file (this bit is working code below) but I want to have an add row button on the form or in the DataGridView that takes the contents of three textboxes and and populates the contents of three columns of the new row. The new row is to be appended to the existing data. Next I would like to

Populate ListView from XML file

僤鯓⒐⒋嵵緔 提交于 2019-12-21 06:17:42
问题 I have the following sample XML file from which i need to poplutate a ListView. I've been playing for hours but I don't know the best way to go about it. I want to use Linq to achieve this but my knowledge is somewhat lacking. It is a Winforms c# project. <DMs> <dataModule> <DMC>11111</DMC> <techName>Test Techname 1</techName> <infoName>info 1</infoName> <status>complete</status> <notes>Note 1</notes> </dataModule> <dataModule> <DMC>22222</DMC> <techName>Test Techname 2</techName> <infoName

How can I load the following XML using LINQ-to-XML into a dictionary?

不问归期 提交于 2019-12-21 05:34:09
问题 How can I load the following formatted XML document: <Settings> <MimeTypes> <MimeType Type="application/mac-binhex40" Extensions=".hqx"/> <MimeType Type="application/msword" Extensions=".doc;.docx"/> <MimeType Type="application/pdf" Extensions=".pdf"/> <MimeType Type="application/vnd.ms-excel" Extensions=".xla;.xlc;.xlm;.xls;.xlt;.xlw;.xlsx"/> </MimeTypes> </Settings> Into a dictionary where the key is an individual extension, and the value is the mimetype. So, for this line: <MimeType Type=

Which is the best for performance wise: XPathNavigator with XPath vs Linq to Xml with query?

有些话、适合烂在心里 提交于 2019-12-21 05:24:05
问题 I have an application in which I am using XPathNavigator to iterate nodes. It is working fine. But I want to know that if I use LINQ to Xml.... What benefits(Performance, maintainability) I will get? With XPath, LINQ to Xml what is the performance hit? I am using C#.net, VS 2010 and my .xml is mid size. 回答1: Well, XPathNavigator will generally be faster than Linq to XML queries. But there's always 'but'. Linq to XML will definitely make your code more readable and maintainable. It's easier

How to generate xsi:schemalocation attribute correctly when generating a dynamic sitemap.xml with LINQ to XML?

你。 提交于 2019-12-21 01:59:49
问题 I am generating a dynamic sitemap.xml According to sitemaps.org this is the header for a sitemap.xml <?xml version='1.0' encoding='UTF-8'?> <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> ... </url> </urlset> So I'm using LINQ To XML to generate the sitemap.xml XNamespace ns = "http://www.sitemaps.org