xmlreader

Reading the Stack Overflow RSS feed

妖精的绣舞 提交于 2019-12-09 14:05:47
问题 I'm trying to get a list of unanswered questions from the feed, but I am having trouble reading it. const string RECENT_QUESTIONS = "https://stackoverflow.com/feeds"; XmlTextReader reader; XmlDocument doc; // Load the feed in reader = new XmlTextReader(RECENT_QUESTIONS); //reader.MoveToContent(); // Add the feed to the document doc = new XmlDocument(); doc.Load(reader); // Get the <feed> element XmlNodeList feed = doc.GetElementsByTagName("feed"); // Loop through each item under feed and add

Parsing through XML elements in XmlReader

落花浮王杯 提交于 2019-12-09 07:12:37
问题 I'm building an application that needs to run through an XML feed but I'm having a little trouble with getting certain elements. I'm using the Twitter feed and want to run through all the <item> elements. I can connect fine and get the content from the feed but I can't figure out how to select only the item elements when I'm loopuing through reader.Read(); . Thanks for your help! 回答1: The easiest way to do that is to use XPath. Example to follow. string xml = @"<?xml version=""1.0"" encoding=

Getting PHP's XMLReader to not throw php errors in invalid documents

筅森魡賤 提交于 2019-12-08 20:33:37
问题 I'm in the process of writing a parser, and trying to do good error handling with exceptions. The following sample code: <?php $xml = <<<XML <?xml version="1.0"?> <rootElem> XML; $reader = new XMLReader(); $reader->xml($xml, null, LIBXML_NOERROR | LIBXML_NOWARNING); $reader->read(); Emits: PHP Warning: XMLReader::read(): An Error Occured while reading in /Users/evert/code/xml/errortest.php on line 11 PHP Stack trace: PHP 1. {main}() /Users/evert/code/xml/errortest.php:0 PHP 2. XMLReader->read

How can I clone MemoryStream object?

假装没事ソ 提交于 2019-12-08 19:28:21
问题 I have a MemoryStream object which is passed by Stream type parameter ( Stream is abstract class in C#). I want to clone him and to create another MemoryStream object a side with current position of the original and to create also a new XMLReader out of it, so I will be able to read its content. This is what I did, and it's not working (debugging the line marked with //* -> newReader has got {None} value) Assumption : you are inside a method and have Stream currentStream reference. var x =

Get XML code count using XMLReader

可紊 提交于 2019-12-08 12:54:32
问题 I am trying to parse product feed that is provided to Google merchant. The thing is I want it to be more interactive so I was using a function that convert XML to array and then show percentage to the user that how much products are updated. I have read that XMLReader is much more efficient then other parsing techniques. How can I make XMLReader more effective. Can I get number of nodes using XMLReader. Or how Can I iterate over XML that it can be more responsive. 回答1: Converting the XML to

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

爱⌒轻易说出口 提交于 2019-12-08 03:43:45
问题 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=

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

妖精的绣舞 提交于 2019-12-08 03:02:23
问题 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>

Detect XML self closing tags with PHP XMLReader

你。 提交于 2019-12-08 02:39:54
问题 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:

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

旧时模样 提交于 2019-12-08 02:08:23
问题 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

XMLStreamReader for Objective C iPhone?

六月ゝ 毕业季﹏ 提交于 2019-12-07 08:42:23
问题 I am using XMLWriter for generating the xml. Now I want to read this xml with some Reader library/framework. Is there any complementary framework/library available for this. I am currently looking to use TouchXML library to read this, but its not working in the expected way as it does not support stream reading. I want do something like: XmlReader pReader = XmlTextReader.Create(pPath); while (pReader.Read()){ switch (pReader.LocalName){ case EXPEL_DEVICES: { //if ((pImportFlags & (int