xmlparser

Difference in performance between Stax and DOM parsing

I have been using DOM for a long time and as such DOM parsing performance wise has been pretty good. Even when dealing with XML of about 4-7 MB the parsing has been fast. The issue we face with DOM is the memory footprint which become huge as soon as we start dealing with large XMLs. Lately I tried moving to Stax (Streaming parsers for ...

FileNotFoundException when reading .xml file to parse

I'm writing a program in Java where I read in data from an XML file and parse it. The file is imported into a folder named "Resources" in the src directory of my project. I'm using Eclipse. When I run the program, I get the following error: java.io.FileNotFoundException: /Users/thechiman/Dropbox/introcs/PSU SOC Crawler/resources/majors_...

What's the best way to retrieve two pieces of data from an XML file?

I've got an XML document that is in either a pre or post FO transformed state that I need to extract some information from. In the pre-case, I need to pull out two tags that represent the pageWidth and pageHeight and in the post case I need to extract the page-height and page-width parameters from a specific tag (I forget which one it i...

Java parsing XML document gives "Content not allowed in prolog." error

I am writing a program in Java that takes a custom XML file and parses it. I'm using the XML file for storage. I am getting the following error in Eclipse. [Fatal Error] :1:1: Content is not allowed in prolog. org.xml.sax.SAXParseException: Content is not allowed in prolog. at com.sun.org.apache.xerces.internal.parsers.DOMParser.par...

Which is much faster, XMLParser or SimpleXML

What do you think guys? I currently using SimpleXML for my entire project, which have average of 250KB in memory usage w/ 500micro seconds processing per execution. I just plan to switch to XMLParser, your advice is much appreciated. Edit : The actual microtime is 0.000578 micro seconds. Im just confused in milli and micro, lol. ...

how do i parse an xml page to output its data pieces to the way i want?

here is the page i want to parse (the api link i gave is just a dev test so its ok to be public) http://api.scribd.com/api?method=docs.getList&api_key=2apz5npsqin3cjlbj0s6m the output im looking for is something like this (for now) Doc_id: 29638658 access_key: key-11fg37gwmer54ssq56l3 secret_password: 1trinfqri6cnv3gf6rnl titl...

Parsing unicode character (0x2) using XML1.1

Hi, In my java application, I need to parse xml that contains control character 0x2 inside CDATA. I tried few ways but coudnt get through. I want to avoid any sort of encoding. Is there any way in XML1.1? Thanks, Shefali ...

How to parse a xhtml ignoring the DOCTYPE declaration using DOM parser

Hi I face issue parsing xhtml with DOCTYPE declaration using DOM parser. Error: java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd%20 Declaration: DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional...

invalid token error while parsing an XML file with UTF-8 encoding

invalid token error while parsing an XML file with UTF-8 encoding. This error is coming when it encountered extended ASCII character 'â' { "â", "â" }. When I have changed the encoding from UTF-8 to ISO-8859-1 the parsing is successful. But my application should support UTF-8, ASCII and extended ASCII characters. What should I do for th...

Reading XML File

I'm developping an iphone application which uses google weather api to forecast the weather. The webservice is giving me data in the following format:- <?xml version="1.0"?> <xml_api_reply version="1"> <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" > <forecast_information> <city data="...

Is it possible to include a DOCTYPE declaration in an XML file and have the parser remove it while working?

Or perhaps have the parser just ignore the DOCTYPE tag in some fashion? I have XML files being used as "!ENTITY"s that also themselves need to have "!ENTITY"s and I have included the nested ones in the top-level file, but Visual Studio calls out my references to those in the 2nd-level files as not defined. Thanks! ...

Special characters in XHTML - Parse Error

When there are special characters like & in the xhtml the DOM / SAX parser throws parse exception. The xhtml document is got as an input for my component. I want to ignore such special characters when i parse. How can i achieve it using DOM/SAX JAVA parser. ...

How to remove accent characters from an InputStream

I am trying to parse a Rss2.0 feed on Android using a Pull parser. XmlPullParser parser = Xml.newPullParser(); parser.setInput(url.open(), null); The prolog of the feed XML says the encoding is "utf-8". When I open the remote stream and pass this to my Pull Parser, I get invalid token, document not well formed exceptions. When I sa...

can i perform xml operations in XMLLITE with the same features of MSXML?

Hi , I know something about MSXML parser ,to create an xml with native code ..Msxml depends COM..So I want to create xml without com and dom ,so i wish to choose XMLLITE..but i dont know full details about xmllite ,when i was read the xmllite documentation in msdn ,i gathered some points ,they will provide only 2 things (IXMLReader & ...

Has NSXMLParser become more strict in iPhone SDK 3.x?

I recently migrated an iPhone project from the 2.2.1 SDK to 3.1.x and, to my surprise, an XML feed that was (and still is with the published app) being parsed by the 2.2.1 NSXMLParser is now causing NSXMLParser to return errors. The XML document in question doesn't meet the W3C standard, but the 2.2.1 parser is able to handle this. I'm...

php output xml produces parse error "&rsquo;"

Hi, Is there any function that I can use to parse any string to ensure it won't cause xml parsing problems? I have a php script outputting a xml file with content obtained from forms. The thing is, apart from the usual string checks from a php form, some of the user text causes xml parsing errors. I'm facing this "&rsquo;" in particula...

how to Download and save xml in documents and then how to parse xml file from documents?

In my app app i have to parsing a xml file downloaded from internet. How to download this xml and save in documents on iphone ? and then how can i start the parsing of XML saved in documents?? ...

Memory leak with autoreleased strings iphone

Hi, I'm trying to clean my app from leaks with Leak instrument. It shows me leaks on xml parser (TBXML). Here is a class I'm going to create upon the parsing: @interface GraphPoint : NSObject { NSString* x; NSString* y; } @property (nonatomic, copy) NSString* x; @property (nonatomic, copy) NSString* y; @end @implementation...

Why am I being warned about the use of an uninitialized value in the following Perl script?

I am trying to cut down the number of ports printed in this list: A.B.C.D 80,280,443,515,631,7627,9100,14000 to the ones that are most interesting for me: A.B.C.D 80,515,9100 To do this, I am using this bit of code: foreach (@ips_sorted) { print "$_\t"; my $hostz = $np->get_host($_); my $port = 0; my $output = ...

Parsing an XML file without root in Java

I have this XML file which doesn't have a root node. Other than manually adding a "fake" root element, is there any way I would be able to parse an XML file in Java? Thanks. ...