xml-parsing

Java: How to prevent 'systemId' in EntityResolver#resolveEntity(String publicId, String systemId) from being absolutized to current working directory

旧巷老猫 提交于 2019-12-05 20:37:27
问题 I want to parse the following XML document to resolve all entities in it: <!DOCTYPE doc SYSTEM 'mydoc.dtd'> <doc>&title;</doc> My EntityResolver is supposed to fetch the external entity with the given system ID from the database and then do the resolution, see below for an illustration: private static class MyEntityResolver { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { // At this point, systemId is always absolutized to the current

Why can't I parse a XML file using QXmlStreamReader from Qt?

淺唱寂寞╮ 提交于 2019-12-05 19:31:06
问题 I'm trying to figure out how QXmlStreamReader works for a C++ application I'm writing. The XML file I want to parse is a large dictionary with a convoluted structure and plenty of Unicode characters so I decided to try a small test case with a simpler document. Unfortunately, I hit a wall. Here's the example xml file: <?xml version="1.0" encoding="UTF-8" ?> <persons> <person> <firstname>John</firstname> <surname>Doe</surname> <email>john.doe@example.com</email> <website>http://en.wikipedia

Extracting data from XML using Java

最后都变了- 提交于 2019-12-05 19:08:43
I have the following XML code: <CampaignFrameResponse xmlns="http://Qsurv/api" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Message>Success</Message> <Status>Success</Status> <FrameHeight>308</FrameHeight> <FrameUrl>http://delivery.usurv.com?Key=a5018c85-222a-4444-a0ca-b85c42f3757d&ReturnUrl=http%3a%2f%2flocalhost%3a8080%2feveningstar%2fhome</FrameUrl> </CampaignFrameResponse> What I'm trying to do is extract the nodes and assign them to a variable. So for example, I'd have a variable called FrameHeight containing the value 308 . This is the Java code I have so far: private void

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

Android XML error message

孤街浪徒 提交于 2019-12-05 17:59:04
问题 Everytime I open an XML layout file, the following error message displays: An internal error occurred during: "Check Android SDK". java.util.ConcurrentModificationException The error message is easily dismiss-able, and my program still runs fine. I have tried restarting Eclipse and my computer with no success. The problem has not always been there, but I am not entirely sure when it started happening. Any ideas or links are appreciated! Example XML file <LinearLayout xmlns:android="http:/

AdMob in android “AdView missing required XML attribute 'adSize' ”

怎甘沉沦 提交于 2019-12-05 15:45:47
I am trying to implement AdMob in my Application. But dont know somehow its showing this error and my R.java file is not being generated due to it. I have tried all the ways to solve this problem, like Clean,Build, Build All. But non is working for me. Following my code snippet in which its showing error "Error in parsing XML: Unbound prefix" <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" android:layout_width="fill_parent" android:layout_height="fill_parent" android

how to parse xml with special character in sql server

断了今生、忘了曾经 提交于 2019-12-05 13:57:07
问题 I am getting following error when i add < in my xml, Msg 9455, Level 16, State 1, Line 6 XML parsing: line 4, character 14, illegal qualified name character How can i parse xml with these type of special characters? DECLARE @MyXML XML SET @MyXML = '<SampleXML> <Colors> <Color1>W < hite</Color1> <Color2>Blue</Color2> <Color3>Black</Color3> <Color4 Special="Light">Green</Color4> <Color5>Red</Color5> </Colors> <Fruits> <Fruits1>Apple</Fruits1> <Fruits2>Pineapple</Fruits2> <Fruits3>Grapes<

xml parsing in python using ElementTree

怎甘沉沦 提交于 2019-12-05 13:19:48
I'm very new to python and I need to parse some dirty xml files which need sanitising first. I have the following python code: import arff import xml.etree.ElementTree import re totstring="" with open('input.sgm', 'r') as inF: for line in inF: string=re.sub("[^0-9a-zA-Z<>/\s=!-\"\"]+","", line) totstring+=string data=xml.etree.ElementTree.fromstring(totstring) print data file.close which parses: <!DOCTYPE lewis SYSTEM "lewis.dtd"> <REUTERS TOPICS="YES" LEWISSPLIT="TRAIN" CGISPLIT="TRAINING-SET" OLDID="5544" NEWID="1"> <DATE>26-FEB-1987 15:01:01.79</DATE> <TOPICS><D>cocoa</D></TOPICS> <PLACES>

Can't read some attributes with SAX

半城伤御伤魂 提交于 2019-12-05 13:19:34
I'm trying to parse that document with SAX: <scxml version="1.0" initialstate="start" name="calc"> <datamodel> <data id="expr" expr="0" /> <data id="res" expr="0" /> </datamodel> <state id="start"> <transition event="OPER" target="opEntered" /> <transition event="DIGIT" target="operand" /> </state> <state id="operand"> <transition event="OPER" target="opEntered" /> <transition event="DIGIT" /> </state> </scxml> I read all the attributes well, except "initialstate" and "name"... I get the attributes with the startElement handler, but the size of the attribute list for scxml is zero. Why? How I

Multiple-types decoder in golang

拜拜、爱过 提交于 2019-12-05 12:51:25
I have an XML document. Some fields have custom format. Example: <document> <title>hello world</title> <lines> line 1 line 2 line 3 </lines> </document> I want to import it into structure like: type Document struct { Title string `xml:"title"` Lines []string `xml:"lines"` } Is there some way how to implement custom decoder, which will split lines string into array of lines ( ["line 1", "line 2", "line 3"] )? Its possible to make Lines field a string type and make split after xml import, but it doesn't seems to be very elegant solution. Is there any way i can define custom decoder for line