parsing

Extract src attribute from script tag and parse according to particular matches

So, I have to determine page type in a proprietary CRM, using JavaScript. The only way to determine the page type (that is, the only consistent difference on the front end) is by examining a script tag (out of many list) whose src attribute begins with /modules/. In a list of a dozen or so script tags in the header, each page has a lin...

How do RSS readers read different feeds?

Hi everyone, sorry for a silly question, (I know it is). I didn't work with RSS before and I have a question. I wrote an RSS reader for iphone which can read one particular feed, if I try to read some other feed it doesn't work properly, I have some data missing, or sometimes it even crashes. Ok, it is naturally enough, because different...

Number of seconds in "HH:MM:SS"

What's the best way to get the number of seconds in a string representation like "hh:mm:ss"? Obviously Integer.parseInt(s.substring(...)) * 3600 + Integer.parseInt(s.substring(...)) * 60 + Integer.parseInt(s.substring(...)) works. But I don't want to test that, and reinvent the wheal, I expect there is a way to use DateTimeFormat or...

Parsing / Extracting the inside of an HTML Tag using Perl?

I've been searching a lot on this the past couple days but still haven't found a clear way to do this... I know its simple to parse HTML with Perl to retrieve the text between tags, but I need to actually retrieve the text inside of a tag instead, such as this: <input type="hidden" name="next_webapp_page" value=""/> Here, I would want...

Parsing Just a specific HTML tag by name or ID in Perl?

This is something thats been hard for me to find info on, I was fortunate to get an answer on the other thing I was trying to do that relates to this (code below).. so say I am using the $content input (in reality it would be a full HTML page, not just the snippet I gave below) and I want to just get the contents of the input tag that ha...

Parsing data into HTML tables and categories

I am to import a file, say june.txt that would have data such as the following data: Sandy,820,384,133,18,408 Wanda,120,437,128,807,595 Jane,631,415,142,687,600 Andrea,179,339,349,594,986 Wanda,803,191,6,807,322 Jane,741,975,34,15,832 Jane,239,714,250,94,497 Andrea,219,188,411,584,713 And t...

XML parsing in jquery doesn't seem to work for me..

I have a static html page weather.html <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <title></title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt; <script type="text/javascript"> $(document).ready(function() { $.ajax({ ...

Parse Raw HTTP in Python

I am looking for a library or function call in python or an associated library that would let me feed in a raw stream of text data representing an HTTP req/res and that would spit out that information is some sort of meaningful form like a dictionary or list. I do not want to use some built in class or create a bunch of new objects, in m...

Elegant parsing of this? "a,b,c",d,"e,f"

I'm looking to parse these kinds of strings into lists in Python: "a,b,c",d,"e,f" => ['a','b','c'] , ['d'] , ['e','f'] "a,b,c",d,e => ['a','b','c'] , ['d'] , ['e'] a,b,"c,d,e,f" => ['a'],['b'],['c','d','e','f'] a,"b,c,d",{x(a,b,c-d)} => ['a'],['b','c','d'],[('x',['a'],['b'],['c-d'])] It nests, so I suspe...

Regular expression help - sum the numbers in a string?

Hi All, Not sure if this is the best approach but I have some string which represents the orientation of some blocks. For example '3V6V' means a row of 3 vertical blocks, and a row of 6 vertical blocks. '3V6V6V' means row of 3, 6, 6 all vertical. '4H4H4H4H' would be 4 rows of 4 horizontal blocks. i.e. every 2 characters constitutes a ro...

Zend File Upload -- Access data in file

I'm building a site in Zend that requires the ability to upload a list of email addresses via a file upload. This will end up populating a distribution list table. What I'd like to do is have the user complete the form, including the attached file, then upon submit, I will parse the file and submit the form for each line of the file. ...

Scrape an HTML Document with jQuery, is it possible?

I want to be able to grab an HTML page and parse it using only Javascript, nothing touches the server. Assuming I can get the html response (solved the cross-domain issues), how can I use jQuery on the complete html document? Example is like this (here is a full gist with a remote example): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...

What is a cross platform regex for removal of line breaks?

I am sure this has been asked before, but I cannot find it. Basically, assuming you are parsing a text file of unknown origin and want to replace line breaks with some other delimiter, is this the best regex, or is there another? (\r\n)|(\n)|(\r) ...

How should parse with PHP (simple html dom parser) background images and other images of webpage?

Hi, How should parse with PHP (simple html dom/etc..) background and other images of webpage? case 1: inline css <div id="id100" style="background:url(/mycar1.jpg)"></div> case 2: css inside html page <div id="id100"></div> <style type="text/css"> #id100{ background:url(/mycar1.jpg); } </style> case 3: separate css file <div i...

Match only backticks not inside a <code> block with Regex.

First things first. I know how to parse XML/HTML with simplexml, and I know all the arguments against using RegEx to parse it. This question is for the sake of knowledge. What needs to happen In a block of text let's say we have the following line of text: The query you need to use is <code>SELECT `post_name` FROM table WHERE id= $id...

Using Double Quotes as Record Separator in AWK

Question says it all. I've tried using awk 'BEGIN{RS=\"} /Match/{print $0}' input and every combination of escaping and quoting I could think of. Any Ideas how to pull this off? ...

whats the best way to parser csv using python ?

I need to develop a script, with input csv file, this file contains multiple headers [headers are language(fr,en,...) specific] and between headers there will be specific data - you can say we've have a well defined CSV template, which will be parsed and will be converted to a specific pydict-dictionary and then this dictionary will be ...

PHP eval and capturing errors (as much as possible)

Disclaimer; I'm fully aware of the pitfalls and "evils" of eval, including but not limited to: performance issues, security, portability etc. The problem Reading the PHP manual on eval... eval() returns NULL unless return is called in the evaluated code, in which case the value passed to return is returned. If there is a par...

what is the best way to parse this file in C#, where i have a CRLF inside a field

i am trying to parse a file that looks like this: || Column Header A || Column Header B || Column Header C ||CRLF | Data A | Data B | Data C |CRLF | Data A | Data B | Data C |CRLF "CRLF" represents a line break i had code to parse this fine: I first parse the file into an array of lines: string[] lines = fileString.Split(Enviro...

Parse string to JSON

Hi, I'm parsing this JSON string with the libs in org.json and I can't understand why I get the output below into the log. ArrayList<String> al = new ArrayList<String>(); JSONObject demo = new JSONObject("{\"00408C88A2E6\":{\"id\":\"00408C88A2E6\",\"name\":\"Lab\"},\"00408C91188B\":{\"id\":\"00408C91188B\",\"name\":\"Lab1\"},\"00408C944...