xmlreader

Reading XML from Stream

爷,独闯天下 提交于 2020-01-11 08:29:08
问题 I'm working with ASP.NET, and am importing an XML file from a form. Right now I convert that into a Stream : Stream inputStream = XmlFileUploadControl.PostedFile.InputStream; because I may need this version later. I'd like to first check to make make sure that the XML file has the correct format, and, if it is, then display some information: if (CorrectFileFormat(inputStream)) { DisplayLicenseInfo(inputStream); } else { StatusLabel.Text = "Selected file is not a LicensingDiag XML file"; } The

Reading Child Nodes with XMLReader

耗尽温柔 提交于 2020-01-07 05:46:28
问题 I'm trying to write an XMLReader/SimpleXML hybrid function to read a very large (700MB) XML file. The XML is in this format: <Items> <Item> <ItemKey>ABCDEF123</ItemKey> <Name> <English>An Item Name</English> <German>An Item Name In German</German> <French>An Item Name In French</French> </Name> <Description> <English>An Item Description</English> <German>An Item Description In German</German> <French>An Item Description In French</French> </Description> </Item> <Item> <ItemKey>GHIJKL456<

Uncompressing xml feed

橙三吉。 提交于 2020-01-07 02:47:09
问题 My application downloads a zipped xml file from the web and tries to create XML reader: var fullReportUrl = "http://..."; // valid url here //client below is an instance of HttpClient var fullReportResponse = client.GetAsync(fullReportUrl).Result; var zippedXmlStream = fullReportResponse.Content.ReadAsStreamAsync().Result; XmlReader xmlReader = null; using(var gZipStream = new GZipStream(zippedXmlStream, CompressionMode.Decompress)) { try { xmlReader = XmlReader.Create(gZipStream, settings);

XMLReader & simpleXML Combo, with Conditions

两盒软妹~` 提交于 2020-01-06 14:15:58
问题 I am using a combination of XMLReader and simpleXML to parse the Posts in a WordPress export file. I realize this is a little out of the norm but, its more of backup project, so we can easily pull up one of these articles if we need it in the futre. The WP site that they were on needs to come down. The issue I am having is that some of the nodes in the XML file are empty or contain useless values (ie. Not full posts). I need to add some string length conditions but, I'm not sure how to check

Can anyone tell me why my XML writer is not writing attributes?

[亡魂溺海] 提交于 2020-01-06 13:57:14
问题 I am writing a parsing tool to help me clean up a large VC++ project before I make .net bindings for it. I am using an XML writer to read an xml file and write out each element to a new file. If an element with a certain name is found, then it executes some code and writes an output value into the elements value. So far it is almost working, except for one thing: It is not copying the attributes. Can anyone tell me why this is happening? Here is a sample of what it is supposed to copy/modify

XML end element is read twice using XMLReader with PHP

冷暖自知 提交于 2020-01-05 09:25:10
问题 I want to read a XML file, using XMLReader but the END ELEMENT is twice called for each element during parsing. <publications> <article id="Xu86oazdn"> <title>Learning</title> <authors> <author> <firstname>Michel</firstname> <lastname>Browsky</lastname> </author> </authors> </article> </publications> This is the piece of code which parse the author entries: <?php $xml = new XMLReader(); $xml->open("php://stdin"); $author = null; while($xml->read()) { switch($xml->nodeType) { case XMLReader:

XML end element is read twice using XMLReader with PHP

扶醉桌前 提交于 2020-01-05 09:23:58
问题 I want to read a XML file, using XMLReader but the END ELEMENT is twice called for each element during parsing. <publications> <article id="Xu86oazdn"> <title>Learning</title> <authors> <author> <firstname>Michel</firstname> <lastname>Browsky</lastname> </author> </authors> </article> </publications> This is the piece of code which parse the author entries: <?php $xml = new XMLReader(); $xml->open("php://stdin"); $author = null; while($xml->read()) { switch($xml->nodeType) { case XMLReader:

XML end element is read twice using XMLReader with PHP

若如初见. 提交于 2020-01-05 09:23:08
问题 I want to read a XML file, using XMLReader but the END ELEMENT is twice called for each element during parsing. <publications> <article id="Xu86oazdn"> <title>Learning</title> <authors> <author> <firstname>Michel</firstname> <lastname>Browsky</lastname> </author> </authors> </article> </publications> This is the piece of code which parse the author entries: <?php $xml = new XMLReader(); $xml->open("php://stdin"); $author = null; while($xml->read()) { switch($xml->nodeType) { case XMLReader:

XMLREADER gives different result when xml is indented

元气小坏坏 提交于 2020-01-03 03:35:07
问题 I have the same XML in two different files. In one file the XML is indented - the other not. The XML is as follows: <?xml version="1.0" encoding="utf-8" ?> <test> <element1></element1> <element2></element2> <element3></element3> </test> When using the following code I get different result with the two files: XmlReaderSettings settings = new XmlReaderSettings { IgnoreComments = true, IgnoreWhitespace = false, IgnoreProcessingInstructions = true }; using (XmlReader reader = XmlReader.Create

Performance: XmlReader or LINQ to XML

筅森魡賤 提交于 2019-12-31 17:39:30
问题 I have a 150 MB XML file which is used as DB in my project. Currently I'm using XmlReader to read content from it. I want to know if it is better to use XmlReader or LINQ to XML for this scenario. Note that I'm searching for an item in this XML and display search result, so it can take a long time or just a moment. 回答1: If you want performance use XMLReader. It doesn't read the whole file and build the DOM tree in memory. It instead, reads the file from disk and gives you back each node it