sax

android utf-8 file parsing

孤人 提交于 2019-12-11 05:03:36
问题 I have some .xml files that are encoded in UTF-8 . But whenever I try to parse them on my tablet (idea pad, lenovo, android 3.1), I get the same error: org.xml.SAXParseException: Unexpected token (position: TEXT @1:2 in java.io.StringReader@40bdaef8). These are the lines that throw the exception: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); InputSource inputSource = new InputSource(); inputSource.setCharacterStream(new

android sax not parsing “dc:creator”?

核能气质少年 提交于 2019-12-11 04:16:47
问题 Hope someone can provide some guidance - i've been using android sax parser with several feeds. Now when I want to parse an item that contains following: <category>category</category> <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">creator</dc:creator> <dc:date xmlns:dc="http://purl.org/dc/elements/1.1/">2011-10-13T07:00:15Z</dc:date> <geo:lat>51.95271682739258</geo:lat> <geo:long>-0.21096819639205933</geo:long> I can get the value of "category" tag, but nothing for the others. The

Parser for JSON in Servlet just like SAX for XML

我只是一个虾纸丫 提交于 2019-12-11 04:08:56
问题 I am using JDOM SAX parser for parsing an external XML file. However i need to parse a JSON in the same servlet. Can anyone suggest parse similar to SAX. 回答1: You should use the Google GSON parser in Java See also the Gson User Guide. 回答2: There is also Jackson: http://jackson.codehaus.org/ 回答3: You can do it with GSON: import java.io.IOException; import java.math.BigDecimal; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; public class JsonProcessor { public

Getting null values after parsing xml file using sax parser in android

南笙酒味 提交于 2019-12-11 02:15:36
问题 After parsing xml file using sax parser I am getting null values for each sub-tag. Although whole file has been parsed but the value showing for each sub field is null. Values are not getting stored and instead null is saved in each field. XML file <markers> <setMarker id="56c6b9c4ef263869678b4567" mlat="12.947014112057" mlng="77.62656211853" slot_id="morning" /> <setMarker id="56c6b9c5ef263869678b4568" mlat="12.941744189945" mlng="77.628879547119" slot_id="morning" /> <setMarker id=

How to copy entire sheets from large excel files without parsing them using Apache POI?

大憨熊 提交于 2019-12-11 01:39:33
问题 I am new as an official user, I always found my answers here but now I have got to ask. I am working with the last apache-poi 3.8 release (from 2012/03/26) and I have to manipulate a single file with multiple sheets in which only one contains a big amount of data (over 1000 columns and 10 000 rows). I only need to had more columns to the big sheet. Therefore, with the current tools that exist I should use SAX to read it and SXSSF to rewrite it. The Excel file is already preformatted with

Java SAXParser parsing invalid xml [duplicate]

怎甘沉沦 提交于 2019-12-11 00:53:09
问题 This question already has answers here : How to parse invalid (bad / not well-formed) XML? (4 answers) Closed 2 years ago . I'm trying to parse some xml which is invalid as the attributes are not in quotes, is there any way of getting around this? A simple example of this below, as well as the java code. XML <car id=1> . . </car> Java SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setValidating(false); SAXParser saxParser = factory.newSAXParser(); saxParser.parse(page,

unknown protocol: c (JDOM a SAXBuilder)

跟風遠走 提交于 2019-12-10 21:14:19
问题 I'm using JDOM with SAXBuilder to parse XML files, and I have a problem with a file which is throwing this error : java.net.MalformedURLException: unknown protocol: c at java.net.URL.<init>(URL.java:574) at java.net.URL.<init>(URL.java:464) at java.net.URL.<init>(URL.java:413) at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source) at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse

How to use the event driven SAX(Simple API FOR XML) parser in C# or is it better to use System.XML namespace?

牧云@^-^@ 提交于 2019-12-10 20:35:43
问题 In C++ we can import msxml DLL to our application and then implement the methods of the interface ISAXContentHandler in a class of our application. Later create an ISAXReader object and invoke the contentHandler with the instance of this class where we have given the implemnatation for the eventhandler interfaces. Similiarly I want to achieve the same thing in C#. Is there any way to do this in C#?? I mean is there any way to have eventbased SAX parsing in C#. There is one more method I

How do I get the correct starting/ending locations of a xml tag with SAX?

心不动则不痛 提交于 2019-12-10 20:05:47
问题 There is a Locator in SAX, and it keep track of the current location. However, when I call it in my startElement(), it always returns me the ending location of the xml tag. How can I get the starting location of the tag? Is there any way to gracefully solve this problem? 回答1: Unfortunately, the Locator interface provided by the Java system library in the org.xml.sax package does not allow for more detailed information about the documentation location by definition. To quote from the

JDom working with XPath

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 19:38:02
问题 I am a newbie to JDom, I try to use XPath to access my xml file. My code is like following: public static void main(String[] args) throws Exception { Document doc = new SAXBuilder().build("file.xml"); XPath x = XPath.newInstance("xpath"); //select the first element in the nodeset Element elem = (Element)x.selectSingleNode(doc); ...... } I have already imported org.jdom.xpath.XPath class. When I use javac to compile the class, it didn't give any error, however when I try to run the program, it