parsing

How does Integer.parseInt(string) actually work?

Was asked this question recently and did not know the answer. From a high level can someone explain how Java takes a character / String and convert it into an int. Many thanks Karl Edit: Would also be good to know if other languages do a similar sort of thing as well. ...

Reading XML using Python minidom and iterating over each node

I have an XML structure that looks like the following, but on a much larger scale: <root> <conference name='1'> <author>Bob</author> <author>Nigel</author> </conference> <conference name='2'> <author>Alice</author> <author>Mary</author> </conference> </root> For this, I used the following code: dom = parse(filepath) conference=dom.ge...

any open source libraries to extract photo/video attachments from email and/or MMS which take care of "hundreds" of test cases

I want to allow users to upload photos and videos with their mobile phone by sending the photo/video to an email address. Cal Henderson in "Building Scalable Web Sites" mentions that Flickr has "hundreds" of test cases to deal with the fact that "Wireless Carriers Hate You". Are there any open source projects/libraries that try to addr...

C Library for Parsing Date Time

Is one aware of a date parsing function for c. I am looking for something like: time = parse_time("9/10/2009"); printf("%d\n", time->date); time2 = parse_time("Monday September 10th 2009") time2 = parse_time("Monday September 10th 2009 12:30 AM") Thank you ...

Parsing Classes, Functions and Arguments in PHP

I want to create a function which receives a single argument that holds the path to a PHP file and then parses the given file and returns something like this: class NameOfTheClass function Method1($arg1, $arg2, $arg2) private function Method2($arg1, $arg2, $arg2) public function Method2($arg1, $arg2, $arg2) abstract class Anot...

Find type of the content (number, date, time, string etc.) inside a string

Hi, I'm trying to parse a CSV file and automatically create a table for it using SQL commands. The first line in the CSV gives the column headers. But I need to infer the column type for each one. Is there any function in Ruby that would find the type of the content in each field. For example, the CSV line: "12012", "Test", "1233.22",...

parse tnsnames.ora using grep to extract hostname minus the domain

Hi I have tnsnames.ora file like DB_CONNECTION1= (description= (address= (protocol=tcp) (host=myhost1.mydomain.com) (port=1234) ) (connect_data= (sid=ABCD) (sdu=4321) ) DB_CONNECTION2= (description= (address= (protocol=tcp) (host=myhost2.mydoma...

.NET Equivalent to DateJS

I like the different human readable strings you can parse with the DateJS javascript project (http://www.datejs.com/). I was wondering if anyone knew of any .NET library that could parse simiilar strings in .NET? ...

Using cocoa how do I get SAX to distinguish endElements in XML when they are the same ?

From the XML below I'm trying to retrieve the second element in the sequence. Notice the end node is the same as the start in each entry, this is making its retrieval a bit tricky. I've tried setting a for loop at the startElementSAX function to evaluate and pick-up the Width="60" attribute. Although this will sort the data correctly i...

Parsing unstructured text in Python

I wanted to parse a text file that contains unstructured text. I need to get the address, date of birth, name, sex, and ID. . 55 MORILLO ZONE VIII, BARANGAY ZONE VIII (POB.), LUISIANA, LAGROS F 01/16/1952 ALOMO, TERESITA CABALLES 3412-00000-A1652TCA2 12 . 22 FABRICANTE ST. ZONE VIII LUISIANA LAGROS, BARANGAY ZONE VIII (POB.), LUISIA...

Allowing variable length lists in yacc

I'd like to be able to parse the following structure: blah { "string-1", "string-2", ..., "string-n" } I'm using flex to tokenize, and that's working perfectly. I'm using yacc (bison) for the parsing. What's the recommended way to allow this structure? Right now, in my test.y file, I've got: blah_command: BLAH OP...

getting charconversion exception for " %" value in query parameter?

i am getting adding some of parameter in query string.value of these param can be "a%%","%" etc.on java code side .while parsing query parameter i m getting char conversionexception as shown below in exception log. 13:14:39,555 ERROR [STDERR] java.io.CharConversionException: EOF 13:14:39,555 ERROR [STDERR] at org.apache.tom...

How to parse XML and insert content into HTML form using jQuery ?

Hello ! I have a simple XMl file with image tags: XML: <img src="images/image1" alt="My Image 1" /> <img src="images/image2" alt="My Image 2" /> <img src="images/image3" alt="My Image 3" /> <img src="images/image4" alt="My Image 4" /> I need to insert this content ("src" attrib) inside a <div> tag in my HTML form. HTML: <div id="p...

jQuery Tablesorter - custom parser not working

I'm trying to write a custom parser for the jQuery plugin, Tablesorter. The idea is for it to sort the numbers in descending order on the first click. However, when I sort the table, the order doesn't change. Sometimes a few rows move, but most of them stay the same. Here is the code: $.tablesorter.addParser({ id: 'desc', is: functio...

Parsing older SpreadsheetML Schemas

I need to parse report files that are generated in an old version of the SpreadsheetML formats (See the HTML Header of the file below) in order to merge multiple single-page reports into a single tabbed workbook with all formatting and contents intact. <HTML xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsof...

Code to parse capture groups in regular expressions into a tree

I need to identify (potentially nested) capture groups within regular expressions and create a tree. The particular target is Java-1.6 and I'd ideally like Java code. A simple example is: "(a(b|c)d(e(f*g))h)" which would be parsed to "a(b|c)d(e(f*g))h" ... "b|c" ... "e(f*g)" ... "f*g" The solution should ideally account for cou...

Fast parsing of PHP in C#

Hello there, I've got a requirement for parsing PHP files in C#. We essentially require some of the devs in another country to upload PHP files and once uploaded we need to check the php files and get a list of all the methods and classes/functions etc. I thought of using a regex but I can't workout if a function belongs to a class etc...

How to understand an EDI file?

I've seen XML before, but I've never seen anything like EDI. How do I read this file and get the data that I need? I see things like ~, REF, N1, N2, N4 but have no idea what any of this stuff means. I am looking for Examples and Documentations. Where can I find them? Aslo EDI guide i found says that it is based on " ANSI ASC X12/ ver....

Java: Parse a mathematical expression given as a string and return a number

Is there a way in Java to get the result from this mathematical expression: String code = "5+4*(7-15)"; Ie, what's the best way to parse an arithmetic expression? ...

Possible to parse a HTML document and build a DOM tree(java)

Is it possible and what tools could be used to parse an html document as a string or from a file and then to construct a DOM tree so that a developer can walk the tree through some API. For example: DomRoot = parse("myhtml.html"); for (tags : DomRoot) { } Note: this is a HTML document not XHtml. ...