parsing

php xml response gave me this after android sax parsing: XML or text declaration not at start of entity

i need to parse this php xml response in android: <?phpxml version="1.0" encoding="utf-8"?> <SmsResponse> <version>1</version> <result>0</result> <resultstring>failure</resultstring> <description>error</description> <endcause></endcause> </SmsResponse> ...

Can PHP SimpleXML be used for this task?

I'm looking to run some kind of loop on some optional XML data. Nodes would potentially look like this: <link1> <url>http://www.bleh.com&lt;/url&gt; <text>Click here</text> </link1> <link2> <url>bleh.com</url> <text>Click here</text> </link2> What would be the best method to determine if these nodes exist and parse them according...

Exceptions with DateTime parsing in RSS feed in C#

I'm trying to parse Rss2, Atom feeds using SyndicationFeedFormatter and SyndicationFeed objects. But I'm getting XmlExceptions while parsing DateTime field like pubDate and/or lastBuildDate. Wed, 24 Feb 2010 18:56:04 GMT+00:00 does not work Wed, 24 Feb 2010 18:56:04 GMT works So, it's throwing due to the timezone field. As a ...

Trouble reading Manufacturer String from HID Device using hid.dll API

I am writing a .NET application that can communicate with HID devices. I want to be able to retrieve and parse the Manufactures String from the device firmware. I know that in the hid.dll there is a method called HidD_GetManufacturerString. MSDN describes this method as follows: BOOLEAN HidD_GetManufacturerString( IN HANDLE Hid...

Is there a simple way in linux to strip a website of text from command line?

I've been searching for a command line tool that would turn html code into just the text that would appear on the site... so it would be equivalent to in a web browser selecting everything and then pasting it into a text editor... Anyone know of something in Ubuntu that would do this? I'm trying to write a script to parse some webpages...

Parsing JSON with JSON.NET

I have a JSON string: {"responseData": {"results": [ {"GsearchResultClass": "GblogSearch", "title":"\u003cb\u003eParis Hilton\u003c/b\u003e shops at Sydney Michelle boutique in the Beverly Glen \u003cb\u003e...\u003c/b\u003e", "titleNoFormatting":"Paris Hilton shops at Sydney Mi...

Getting fast translation of string data transmitted via a socket into objects in Python

I currently have a Python application where newline-terminated ASCII strings are being transmitted to me via a TCP/IP socket. I have a high data rate of these strings and I need to parse them as quickly as possible. Currently, the strings are being transmitted as CSV and if the data rate is high enough, my Python application starts to ...

Dynamic HTML to PDF

Hi guys I need to be able to convert dynamic HTML (html that is rendered on page load by javascript) to a PDF. I know there are plenty of HTML to PDF converters but none of the ones I have found thus far cope with dynamic HTML. The given tool should be able to successfully convert the following page - http://www.simile-widgets.org/tim...

Accepting only Valid Time

Alright so in Java I want to ask the user for a time in 24-hour format. I have managed to leverage DateFormat and SimpleDateFormat to tell it what format the time is being entered in and then to interpret that accordingly, throwing an exception if it does not follow that format. Here is what I have: DateFormat fmt = new SimpleDateFormat...

delimiter for parsing message with unknown length (best practice?) java

hi, I have a byte array (UTF-8 encoded string send as byte array from client). The message should have the following format: 'number' 'timestamp' 'str1' 'str2' E.g 1 2000-01-31T20:00.00 the 1st str the 2nd str It is clear that the 'number' and 'timestamp' are easily read from the byte array. The start position of 'str1' can be also...

How do I parse a string for a particular delimited section within PHP?

Hi folks, I have a string, for example "[{XYZ123}] This is a test" and need to parse out the content in between the [{ and }] and dump into another string. I assume a regular expression is in order to accomplish this but as it's not for the faint of heart, I did not attempt and need your assistance. What is the best way to pull the fr...

Parsing XML on iPhone created in PHP

Hello, i'm trying to parse a xml string with NSXMLParser which i created in PHP. My PHP sript is: $doc = new DomDocument('1.0'); //$doc->preserveWhiteSpace=false; $root = $doc->createElement("root"); $root = $doc->appendChild($root); $child = $doc->createElement("child"); $child = $root->appendChild($child); $value = $doc->createTextNo...

vb.net address parsing question

i need to parse normail mailing addresses in vb.net. the requirement is address shall be split in 2 variables. so if address is 12300 euclid st. then it will be "12300" and "euclid st." in two different variables. also if address is 123 B4 euclid st then "123 B4" and "euclid st". Sometimes address is 12008 B2 euclid st Apt 12. In this c...

PHP parse directory and subdirectories for file paths and names of only jpg image types

I am looking to modify this php code to do a recursive "search for and display image" on a single, known, directory with an unknown amount of sub-directories. Here's the code I have that scans a single directory and echoes the files out to html: <?php foreach(glob('./img/*.jpg') as $filename) { echo '<img src="'.$fil...

Testing intersection of two regular languages

I want to test whether two languages have a string in common. Both of these languages are from a subset of regular languages described below and I only need to know whether there exists a string in both languages, not produce an example string. The language is specified by a glob-like string like /foo/**/bar/*.baz where ** matche...

Parse mail for mail quoted part

Hi Is there any way to extract the mail quoted part from the replied mails? I noticed Gmail appends the ">" character prefix to each line for identifying the quoted part. But each mail client behaves differently for identifying mail quoted aprt. Hence I can not follow the single pattern to solve the issue. Can you please post the...

XML parser and its advantages and disadvantages

Hi I have heard a lot about XML parser but I want to know i.e 2 kinds of it and also the advantages and disadvantages of each one! please help me thanks ...

json parse error in ruby - unexpected token at

Hi, I get errors at a lot of places when trying to retrieve ticker symbols for US companies from http://d.yimg.com/autoc.finance.yahoo.com/autoc?callback=YAHOO.Finance.SymbolSuggest.ssCallback&amp;query=Wal-Mart I have tried to: resp = Net::HTTP.get_response(URI.parse(url)) data = resp.body qwe = data.split("symbol") p qwe[1] arr1 = ...

PHP DOMDocument - get html source of BODY

I'm using PHP's DOMDocument to parse and normalize user-submitted HTML using the loadHTML method to parse the content then getting a well-formed result via saveHTML: $dom= new DOMDocument(); $dom->loadHTML('<div><p>Hello World'); $well_formed= $dom->saveHTML(); echo($well_formed); This does a beautiful job of parsing the fragment and...

How do I display all pronouns in a sentence and their persons using antlr

EDITED according to WayneH's grammar Here's what i have in my grammar file. grammar pfinder; options { language = Java; } sentence : ((words | pronoun) SPACE)* ((words | pronoun) ('.' | '?')) ; words : WORDS {System.out.println($text);}; pronoun returns [String value] : sfirst {$value = $sfirst.value; System.o...