sax

What is the right way to get attribute value in libXML sax parser (C++)?

可紊 提交于 2019-12-05 22:01:46
I am using the SAX interface of libXML to write a XML parser application in C++. <abc value="xyz "pqr""/> how do I parse this attribute? I tried using void startElementNsSAX2Func(void * ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar ** namespaces, int nb_attributes, int nb_defaulted, const xmlChar ** attributes) , incrementing attributes parameter( and checking for a " to indicate the end of the attribute value). It works for all the attributes other than *"* appearing in the attribute value. What is the right method to parse these

The markup must be well-formed

依然范特西╮ 提交于 2019-12-05 21:40:24
问题 First off, let me say I am a new to SAX and Java. I am trying to read information from an XML file that is not well formed. When I try to use the SAX or DOM Parser I get the following error in response: The markup in the document following the root element must be well-formed. This is how I set up my XML file: <format type="filename" t="13241">0;W650;004;AG-Erzgeb</format> <format type="driver" t="123412">001;023</format> ... Can I force the SAX or DOM to parse XML files even if they are not

readstream pipe does not close

与世无争的帅哥 提交于 2019-12-05 20:56:54
I am using sax-js to read large xml files. I cannot get the program to exit when the parser is finished. Here is the shape of the script, with parser logic removed. var fs = require('fs'); var sax = require('sax'); var feedFile = 'foo.xml'; var saxStream = sax.createStream(true) .on('opentag', function(node) { // do stuff }) .on('end', function() { console.log("parser end event"); }); var options = { flags: 'r', encoding: 'utf8', mode: 0666, bufferSize: 1024 }; fs.createReadStream(feedFile, options, function(err) { throw err; }) .on('end', function() { console.log("read stream end event"); })

Referring to a local DTD in Java

六眼飞鱼酱① 提交于 2019-12-05 20:02:24
问题 I have some XML that I'm parsing with a SAX parser in Java. It starts with this preamble: <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 3.0//EN" "http://www.w3.org/Math/DTD/mathml3/mathml3.dtd"> How do I change this to use a local DTD? I suppose I could do something like this: <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 3.0//EN" "file:///c:/MathML/mathml3.dtd"> Not exactly like that, but something like that. However, I need the path to be independent of the user's system. How do I use a local DTD

How to tidy up malformed xml in ruby

怎甘沉沦 提交于 2019-12-05 18:59:30
I'm having issues tidying up malformed XML code I'm getting back from the SEC's edgar database . For some reason they have horribly formed xml. Tags that contain any sort of string aren't closed and it can actually contain other xml or html documents inside other tags. Normally I'd had this off to Tidy but that isn't being maintained. I've tried using Nokogiri::XML::SAX::Parser but that seems to choke because the tags aren't closed. It seems to work alright until it hits the first ending tag and then it doesn't fire off on any more of them. But it is spiting out the right characters. class

Java XML Parsing and original byte offsets

主宰稳场 提交于 2019-12-05 18:24:07
问题 I'd like to parse some well-formed XML into a DOM, but I'd like know the offset of each node's tag in the original media. For example, if I had an XML document with the content something like: <html> <body> <div>text</div> </body> </html> I'd like to know that the node starts at offset 13 in the original media, and (more importantly) that "text" starts at offset 18. Is this possible with standard Java XML parsers? JAXB? If no solution is easily available, what type of changes are necessary

Parse a list of XML fragments with no root element from a stream input

天涯浪子 提交于 2019-12-05 18:20:16
问题 Is it feasible in Java using the SAX api to parse a list of XML fragments with no root element from a stream input? I tried parsing such an XML but got a org.xml.sax.SAXParseException: The markup in the document following the root element must be well-formed. before even the endDocument event was fired. I would like not to settle with obvious but clumsy solutions as "Pre-append a custom root element or Use buffered fragment parsing". I am using the standard SAX API of Java 1.6. The SAX

SAX parsing: how to fetch child nodes

荒凉一梦 提交于 2019-12-05 14:40:52
I'm using SAX parsing in android. For below XML: <?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <channel> <title>Game Analysis</title> <item> <title>GTA</title> <description>ABC</description> <pubDate>Sat, 21 Feb 2012 05:18:23 GMT</pubDate> <enclosure type="audio/mpeg" url="http://URL.mp3" length="6670315"/> </item> <item> <title>CoD</title> <description>XYZ</description> <pubDate>Sat, 21 Feb 2011 05:18:23 GMT</pubDate> <enclosure type="audio/mpeg" url="http://URL.mp3" length="6670315"/> </item> </channel> </rss> I need to fetch the first occurance of <title> (just below ). Then

Batik with grails giving sax clash

北城余情 提交于 2019-12-05 14:15:21
I'm trying to use batik with grails to render some SVG stuff to PNG on the server. I'm getting the following error in IntelliJ when I add the dependencies to BuildConfig and then tell IntelliJ to load the changes: /Library/Java/JavaVirtualMachines/1.6.0_33-b03-424.jdk/Contents/Home/bin/java -Dgrails.home=/Applications/Dev/grails-2.1.0 -Dbase.dir=/Users/greg/Documents/development/git/liftyourgame-grails/webapp -Dtools.jar=/Library/Java/JavaVirtualMachines/1.6.0_33-b03-424.jdk/Contents/Home/lib/tools.jar -Dgroovy.starter.conf=/Applications/Dev/grails-2.1.0/conf/groovy-starter.conf -Xmx512M -XX

XML SAX parser for scripting using reflection

故事扮演 提交于 2019-12-05 13:30:58
I'd like an opinion about to create an hypothetic scripting system using XML. The idea is to use a SAX parser and C# reflection. I cannot find a library/framework which allow to specify custom action using XML files. At this time I use XML for serialize application classes, bug could be awesome to specify which actions the application shall execute using XML. So, I'm thinking about: SAX parser implementation for C#? XML script conventions? What I'd like to achieve is the: - Possibility to assign a class instance property - Possibility to call class instance routines Assuming that the class