xmlreader

Is there an XmlReader equivalent for HTML in .Net?

妖精的绣舞 提交于 2019-12-07 07:54:47
问题 I've used HtmlAgilityPack in the past to parse HTML in .Net but I don't like the fact that it only uses a DOM model. On large documents and/or those with heavy levels of nesting it is possible to hit stack overflow or out of memory exceptions. Also in general a DOM based parsing model uses significantly more memory than a streaming based approach, typically because the process that wants to consume the HTML may only need a few elements to be available at a time. Does anyone know of a decent

LINQ to XML vs. XmlReader

廉价感情. 提交于 2019-12-07 05:13:27
问题 In my Silverlight application I'm using mostly XmlReader but I'm playing with idea to replace XmlReader implementation with LINQ to XML. What are pros and cons between LINQ to XML and XmlReader in Silverlight? 回答1: PROs of Linq to XML Query XML documents with the same LINQ syntax your used to Uses the same X objects that you're used to working with (XElement, etc.) PROs of using XmlReader Finer grain control over the query syntax (XPath rather than LINQ) ...personally, I switched to LINQ to

How to use XMLReader to parse multiple, identically named attributes of XML element/sub-element

馋奶兔 提交于 2019-12-06 15:06:31
I'm using XMLReader and PHP to process a moderately-sized XML file (6mb) and basically break up the attribute data and insert it into my own database. Problem is, each element has a variable number of subelements with identically named attributes. Here's an example (this is open data about the government courtesy of govtrack.us): <?xml version="1.0" ?> <people> <person id='400001' lastname='Abercrombie' firstname='Neil' birthday='1938-06-26' gender='M' pvsid='26827' osid='N00007665' bioguideid='A000014' metavidid='Neil_Abercrombie' youtubeid='hawaiirep1' name='Rep. Neil Abercrombie [D, HI-1]'

How to update this xml file with PHP XML reader & writer?

浪尽此生 提交于 2019-12-06 14:46:26
问题 I have the following sitemap XML which contains a list of URLs to be submitted for search engines. I took this example code from another SO answer. // Init XMLWriter $writer = new XMLWriter(); $writer->openURI(APPLICATION_PATH . '/sitemap.xml'); // document head $writer->startDocument('1.0', 'UTF-8'); $writer->setIndent(4); $writer->startElement('urlset'); $writer->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); // Write something // this will write: <url><loc>some url

Get xml attribute values as string[]

。_饼干妹妹 提交于 2019-12-06 11:34:38
My xml file has something like this: ... <Keyword name = "if" /> <Keyword name = "else" /> <Keyword name = "is" /> ... So how can I recursively get all of the values of the name attribute and add them to a List<string> or string[] . Maybe a foreach loop? I followed codemeit's and I keep getting an error: Data at the root level is invalid. Line 1, position 1. My xml file is <KeyWords> ... <KeyWord name = "if" /> ... </KeyWord> New problem The '\' character, hexadecimal value 0x5C, cannot be included in a name. but the same file. Assume let variable testXml is equal to the follow xml string

How to parse an XML node with a colon tag using PHP

风格不统一 提交于 2019-12-06 11:19:32
I am trying to fetch the value of the following nodes from [this URL (takes quite some time to load)][1]. The elements I'm interested in are: title, g:price and g:gtin The XML starts like this: <rss xmlns:g="http://base.google.com/ns/1.0" version="2.0"> <channel> <title>PhotoSpecialist.de</title> <link>http://www.photospecialist.de</link> <description/> <item> <g:id>BEN107C</g:id> <title>Benbo Trekker Mk3 + Kugelkopf + Tasche</title> <description> Benbo Trekker Mk3 + Kugelkopf + Tasche Das Benbo Trekker Mk3 ist eine leichte Variante des beliebten Benbo 1. Sein geringes Gewicht macht das

Detect XML self closing tags with PHP XMLReader

一世执手 提交于 2019-12-06 11:02:37
I'd like to parse one XML document using XMLReader. I have a case switch with all the Constants. However, if a Tag is self-closing XMLReader only fires ELEMENT, not ELEMENT and than END_ELEMENT like expected. Detection through class property $isEmptyElement does also not work because the tag has attributes. Therefore my question: How to detect a self-closing XML tag with XMLReader in PHP? Related but no solution: XmlReader - Self-closing element does not fire a EndElement event? Example Node: <mynode name="somenamestring" code="intstring" option="intstring3"/> My Code: $xmlReader->open($url

How to read an XML file with an undefined namespace with XMLReader?

自古美人都是妖i 提交于 2019-12-06 06:58:33
I'm relatively new to parsing XML files and am attempting to read a large XML file with XMLReader. <?xml version="1.0" encoding="UTF-8"?> <ShowVehicleRemarketing environment="Production" lang="en-CA" release="8.1-Lite" xsi:schemaLocation="http://www.starstandards.org/STAR /STAR/Rev4.2.4/BODs/Standalone/ShowVehicleRemarketing.xsd"> <ApplicationArea> <Sender> <Component>Component</Component> <Task>Task</Task> <ReferenceId>w5/cron</ReferenceId> <CreatorNameCode>CreatorNameCode</CreatorNameCode> <SenderNameCode>SenderNameCode</SenderNameCode> <SenderURI>http://www.example.com</SenderURI> <Language

“java.net.UnknownHostException” occur when read mybatis xml file

≡放荡痞女 提交于 2019-12-06 05:56:10
I like to read data from following mybatis xml file by java code. (Not mybatis mapping, just want to read data form outside application.) <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.raistudies.persistence.UserService"> <resultMap id="result" type="user"> <result property="id" column="id"/> <result property="name" column="name"/> <result property="standard" column="standard"/> <result property="age" column="age"/> <result property="sex" column="sex"/> </resultMap>

Why is the XmlReader skipping elements?

会有一股神秘感。 提交于 2019-12-06 05:30:05
问题 Please note this question is specific to XmlReader and not whether to use XDocument or XmlReader . I have an XML fragment as: private string GetXmlFragment() { return @"<bookstore> <book genre='novel' ISBN='10-861003-324'> <title>The Handmaid's Tale</title> <price>19.95</price> </book> <book genre='novel' ISBN='1-861001-57-5'> <title>Pride And Prejudice</title> <price>24.95</price> </book> </bookstore>"; } I also have an extension method as: public static IEnumerable<XElement> GetElement(this