xml-parsing

Validating a large XML file ~400MB in PHP

走远了吗. 提交于 2019-12-06 03:17:58
问题 I have a large XML file (around 400MB) that I need to ensure is well-formed before I start processing it. First thing I tried was something similar to below, which is great as I can find out if XML is not well formed and which parts of XML are 'bad' $doc = simplexml_load_string($xmlstr); if (!$doc) { $errors = libxml_get_errors(); foreach ($errors as $error) { echo display_xml_error($error); } libxml_clear_errors(); } Also tried... $doc->load( $tempFileName, LIBXML_DTDLOAD|LIBXML_DTDVALID ) I

Clojure Leining REPL OutOfMemoryError Java heap space

青春壹個敷衍的年華 提交于 2019-12-06 03:04:28
问题 I am trying to parse a fairly small (< 100MB) xml file with: (require '[clojure.data.xml :as xml] '[clojure.java.io :as io]) (xml/parse (io/reader "data/small-sample.xml")) and I am getting an error: OutOfMemoryError Java heap space clojure.lang.Numbers.byte_array (Numbers.java:1216) clojure.tools.nrepl.bencode/read-bytes (bencode.clj:101) clojure.tools.nrepl.bencode/read-netstring* (bencode.clj:153) clojure.tools.nrepl.bencode/read-token (bencode.clj:244) clojure.tools.nrepl.bencode/read

How Can I Speed Up Android XML Parsing?

空扰寡人 提交于 2019-12-06 02:56:32
问题 Good afternoon (depending on where you live)! I'm fairly new to Android development and I'm currently working on moving the functionality from an existing iOS app to Android. Part of this functionality is to parse a "large" (~13,000 line) RSS XML file that contains about 500 entries. I've spent anywhere from 10-15 hours researching XML parsing on Android AND trying out the major XML parsers: DOM, SAX, and Pull-parsing. Here are my results, running within' the emulator on my box (32-bit

Writing from Java to an XML document - Simple

筅森魡賤 提交于 2019-12-06 02:49:55
I know there's tons of questions on writing from Java to XML on stackoverflow, but it's all too complex. I feel I have a very simple problem that I just can't figure out. So I have a program that takes a bunch of user input and I have it currently creating and appending a text document with the results. I'll just post my writer code here: PrintWriter out = null; try { out = new PrintWriter(new BufferedWriter(new FileWriter("C:/Documents and Settings/blank/My Documents/test/test.txt", true))); out.println(""); out.println("<event title=\""+titleFieldUI+"\""); out.println(" start=\""+monthLongUI

Add one row to TableView each day app used

六眼飞鱼酱① 提交于 2019-12-06 02:33:43
I am building an app that will be used as a daily reading guide. The data is all stored in an XML that will be stored in app, and sorted based off pubDate. On the number of rows in each section code, if I put in just a number, I get errors, but if I put in the [array count]; it shows every single item. Could I get some suggestions for what to do to accomplish my goal? EDIT: Here is more code to my app. I use ASIHTTPRequest and GDataXML to parse the XML and store each item in an array. What I am trying to do is show only earliest entry day 1, add the next day 2, and so forth. If I put in any

Parsing multiple XML fragments with STaX

本小妞迷上赌 提交于 2019-12-06 01:24:07
I was hoping the following would be parseable in StAX, <something a="b"/> <something a="b"/> But it chokes when you reach the second element. As there is no common root element. (I'm not too sure why a pull parser cares about this particular issue... anyway...) I can fake a root element, e.g. Guava: InputSupplier<Reader> join = CharStreams.join( newReaderSupplier("<root>"), newReaderSupplier(new File("...")), newReaderSupplier("</root>")); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader xsr = xif.createXMLStreamReader(join.getInput()); xsr.nextTag(); // Skip the fake root

getElementById for XML Documents, Mozilla extensions

最后都变了- 提交于 2019-12-06 01:17:27
Is document.getElementById method supported on DOM parsed from XML strings using the DOMParser method in Mozilla? I am making a Mozilla extension that reads an XML file and uses DOM Parser to convert the XML into a DOM element and tries getting elements by Id. The method getElementsByTagName works but not getElementById. It always returns null. function (xmlString) { var parser = new DOMParser(); var doc = parser.parseFromString(xmlString, "text/xml"); var aNodes = doc.getElementsByTagName("nodeTag"); for(var i=0; i<aNodes.length; ++i) { var id = aNodes[i].getAttribute('id'); var resultNode =

How to get a particular element through JAXB xml parsing?

天大地大妈咪最大 提交于 2019-12-05 23:38:13
问题 I have used JAXB to parse an XML.How to get a particular element(ie a child node) through JAXB xml parsing without parsing that element as node. <?xml version="1.0" encoding="UTF-8"?> <Header> <From> <Credential domain="NetworkId"><Identity>ANXXXNNN</Identity> </Credential> </From> <To> <Credential domain="NetworkId"><Identity>ANNNXXXXXT</Identity> </Credential> </To> <To> <Credential domain="NetworkId"><Identity>BNNXXXT</Identity> </Credential> </To> </Header> I have done unmarshalling like

XPath to get all text in element as one value, removing line breaks

余生颓废 提交于 2019-12-05 22:42:59
问题 I am trying to get all the text in a node for a following set and returning as one value (not multiple nodes). <p> "I love eating out." <br> <br> "This is my favorite restaurant." <br> "I will definitely be back" </p> I am using '/p' and get all the results but it returns with line breaks. Also trying '/p/text()' results in getting each text between each tag as a separate returned value. The ideal return would be -- "I love eating out. This is my favorite restaurant. I will definitely be back

Groovy: copy XML elements from one doc to another

折月煮酒 提交于 2019-12-05 20:50:43
I am new to Groovy and am stuck with a simple problem. All I wanna do is extract certain elements from one XML file and created a new file with it. Here's an example XML, let's use a Maven pom file: <project> <modelVersion>4.0.0</modelVersion> <groupId>com.group</groupId> <artifactId>artifact</artifactId> <version>1.4</version> <dependencyManagement> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> </dependencies> </dependencyManagement> I know how to parse XML in Groovy: def project = new XmlParser()