xmlreader

Read stream from XmlReader, base64 decode it and write result to file

僤鯓⒐⒋嵵緔 提交于 2019-12-02 19:41:16
问题 Basically, I want to extract the stream from the XmlReader and directly base64 decode it to a file. The structure of the XML file can be seen here. To get the value I have to use ReadInnerXml() . Is it possible to use ReadValueChunk instead? Here is my current code: using (XmlReader reader = XmlReader.Create("/your/path/47311.xml")) { while(reader.Read()) { if (reader.IsStartElement () && reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "ttOutputRow": reader

Working with a forest of binary trees stored in a large XML file (PHP)

非 Y 不嫁゛ 提交于 2019-12-02 14:16:52
问题 I have an array like 'var1'=>1.05, 'var2'=>0.76,... and a forest of binary trees stored in a 100+ MB XML file. <Tree id="1"> <Node id="2"> <SimplePredicate field="var1" operator="lessOrEqual" value="1.41"/> <Node id="4"> <SimplePredicate field="var2" operator="lessOrEqual" value="1.43"/> ....... </Node> </Node> <Node id="3"> <SimplePredicate field="var1" operator="greaterThan" value="1.41"/> ....... </Node> </Tree> What I'd like to do in PHP is for each tree to store properties of a leaf in

XMLReader - How to handle undeclared namespace

☆樱花仙子☆ 提交于 2019-12-02 12:49:22
I'm reading a large ~300Mb gzipped XML file with XMLReader that get's automatically dumped to my server nightly (archaic, I know..) It is malformed ie, it has an undefined namespace and it's throwing an error ErrorException [ Warning ]: XMLReader::read() namespace error : Namespace prefix xsi for AttrName on NodeName is not defined What is the best way to deal with this? It seems impractical to uncompress, load the whole thing into memory, replace a string, write it again -- gzipped. The file is huge. The whole reason I'm using XMLReader is to prevent loading the whole file into memory during

Working with a forest of binary trees stored in a large XML file (PHP)

风格不统一 提交于 2019-12-02 12:13:55
I have an array like 'var1'=>1.05, 'var2'=>0.76,... and a forest of binary trees stored in a 100+ MB XML file. <Tree id="1"> <Node id="2"> <SimplePredicate field="var1" operator="lessOrEqual" value="1.41"/> <Node id="4"> <SimplePredicate field="var2" operator="lessOrEqual" value="1.43"/> ....... </Node> </Node> <Node id="3"> <SimplePredicate field="var1" operator="greaterThan" value="1.41"/> ....... </Node> </Tree> What I'd like to do in PHP is for each tree to store properties of a leaf in which I'll end up based on the conditions given by each node. So in this example the path will be (2)->

Correcting XmlReader problems using ReadToDescendant and/or ReadElementContentAsObject

柔情痞子 提交于 2019-12-02 09:54:17
问题 I'm working on a mysterious bug in the usually very good open source project Excel Data Reader. It's skipping values reading from my particular OpenXML .xlsx spreadsheet. The problem is occurring in the ReadSheetRow method (demonstration code below). The source XML is saved by Excel and contains no whitespace which is when the strange behaviour occurs. However XML that has been reformatted with whitespace (e.g. in Visual Studio go to Edit, Advanced, Format Document) works completely fine!

PHP xmlreader to array

China☆狼群 提交于 2019-12-02 06:13:10
The following test function reads an XML file with PHP's xmlreader and returns a 2 dimensional array of 3 values ("id" = key). How can you edit the code so that the username key and value is returned in the array also? (shown at the end) ini_set('always_populate_raw_post_data', 'on'); function test() { $request = $HTTP_RAW_POST_DATA; error_reporting(E_ERROR | E_WARNING | E_PARSE); $url = "http://site.xml"; $reader = new XMLReader(); $reader->open($url);; $var = array(); $i = 0; $limit = 3; while ($reader->read()) { if ($reader->name == "id" && $reader->nodeType == XMLReader::ELEMENT) { if ($i

Correcting XmlReader problems using ReadToDescendant and/or ReadElementContentAsObject

旧巷老猫 提交于 2019-12-02 06:06:37
I'm working on a mysterious bug in the usually very good open source project Excel Data Reader . It's skipping values reading from my particular OpenXML .xlsx spreadsheet. The problem is occurring in the ReadSheetRow method (demonstration code below). The source XML is saved by Excel and contains no whitespace which is when the strange behaviour occurs. However XML that has been reformatted with whitespace (e.g. in Visual Studio go to Edit, Advanced, Format Document) works completely fine! Test data with whitespace: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="http

XML with varying amount of child nodes for each parent node

喜你入骨 提交于 2019-12-02 05:19:11
So I have XML in the following format which I am reading from file 'test.xml' <XML> <Agent ID="ABC123"> <Property> <Code>XYZ</Code> <Name>Hotel 1</Name> </Property> <Property> <Code>237</Code> <Name>Hotel 2</Name> </Property> <Property> <Code>213</Code> <Name>Hotel 3</Name> </Property> </Agent> <Agent ID="DEF456"> <Property> <Code>333</Code> <Name>Hotel 4</Name> </Property> <Property> <Code>23423</Code> <Name>Hotel 5</Name> </Property> </Agent> <Agent ID="GHI789"> <Property> <Code>45345</Code> <Name>Hotel 6</Name> </Property> </Agent> </XML> I want to be able to output the above into the

Prevent XmlReader from expanding XML entities

随声附和 提交于 2019-12-01 22:57:14
问题 Is there a way to prevent .NET's XmlReader class from expanding XML entities into their value when reading the content? For instance, suppose the following XML is used as input: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE author PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML" "http://www.oasis-open.org/docbook/xmlcharent/0.3/iso-lat1.ent" > <author>á</author> Let's assume it is not possible to reach the external OASIS DTD needed for the expansion of the aacute

Prevent XmlReader from expanding XML entities

扶醉桌前 提交于 2019-12-01 20:26:10
Is there a way to prevent .NET's XmlReader class from expanding XML entities into their value when reading the content? For instance, suppose the following XML is used as input: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE author PUBLIC "ISO 8879:1986//ENTITIES Added Latin 1//EN//XML" "http://www.oasis-open.org/docbook/xmlcharent/0.3/iso-lat1.ent" > <author>á</author> Let's assume it is not possible to reach the external OASIS DTD needed for the expansion of the aacute entity. I would like the reader to read, in sequence, the author element, then the aacute node of type