parsing

C# generic string parse to any object

I am storing object values in strings e.g., string[] values = new string[] { "213.4", "10", "hello", "MyValue"}; is there any way to generically initialize the appropriate object types? e.g., something like double foo1 = AwesomeFunction(values[0]); int foo2 = AwesomeFunction(values[1]); string foo3 = AwesomeFunction(values[2]); MyEnu...

how to get the node inside the parent node in touch xml parsing

Hi all I am parsing my xml with libxml ,my code is as follows -(void) grabRSSFeed:(NSString *)blogAddress { // Initialize the blogEntries MutableArray that we declared in the header blogEntries = [[NSMutableArray alloc] init]; // Convert the supplied URL string into a usable URL object NSURL *url = [NSURL URLWithString: blogAddr...

How do Search Engines find relevant content ?

How does Google find relevant content when its parsing the web? Lets say for instance, Google uses the PHP native DOM Library to parse content, What methods would they be for it to find the most relevant content on a web page. My thoughts would be that it would search for all paragraphs, order by the length of each paragraph and then f...

How to select a <td> by his bgcolor attribute using PHP simple html dom parser

I have to extract this particular HTML using PHP. Since I haven't any class or unique ID I tried to use his bgcolor attrib but without success... <td bgcolor="#F5EC97" width="154" valign="top" align="left" height="55"> <font face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><font color="#CC6633">CITY</font></b><br>...

Parsing HTML / Javascript into a MySQL database

I'm looking for suggestions as to the best way to parse the following calendar... http://www.ucd.ie/events/calendar . I can't detect any well known framework being used nor can I find it in RSS/XML/JSON format. The only possible way to parse the following that I see is to parse the raw HTML which is far from ideal especially since many...

Parsing JSON query (and xml)

I would need to parse some data that i get from JSON query. I get the data with $.getJSON(JSONquery, function(data){ $.each(data, function(i,item){ $('#output.... }); The data I get from it something like this (sorry its messy and longish): [{"name":"139930 blablabla","id":599,"contentobject_id":599,"main_node_id":565,"modified":...

Converting time durations from string to float

I'm working on an Android application that tracks time durations of tasks. Internally, it saves these durations as a float representing how many hours were spent on the task. So 30 minutes would be 0.5, 1 hour would be 1, etc. I've got all that code working great, along with code to convert these into hh:mm format for easier reading. ...

How to choose a proper Python parser generator to parse C struct definitions?

Hi, I am working on a project which contains two servers, one is written in python, the other in C. To maximize the capacity of the servers, we defined a binary proprietary protocol by which these two could talk to each other. The protocol is defined in a C header file in the form of C struct. Usually, I would use VIM to do some subst...

Java XML Parser for huge files

Hi, I need a xml parser to parse a file that is approximately 1.8 gb. So the parser should not load all the file to memory. Any suggestions? ...

Parsing restructured text in django (and python)

I'm going to manage some documentation using Django (I come from Sphinx) in order to have more control on the output. The docs are in rst (restructured text) in a git archive, and it's trivial to display them in HTML using a filter. My problem is that they are quite long, and I'd like to have more control on how the pagination goes, so I...

Need to set up a byte[]

The goal is to get a byte[16] where the first element is hex value 55 and the second element is hex value AA. And the other 14 are hex value 0. I tried byte[] outStream = System.Text.Encoding.UTF8.GetBytes("55 AA 00 00 00 00 00 00 00 00 00 00 00 00 00 00"); but this fills the byte[] with the ascii values, not the hex values. I tri...

Is there a C# framework for parsing and validating CSV/XML files uploaded to an ASP.NET site?

I have a product-based website and I'd like to expand the number of file formats/layouts that we accept for inventory uploads. Ideally that would be done using some existing implementation that supports various file formats and assists in validating and allowing user corrections to the uploaded data. Anything giant and "servery" like Bi...

parsing parenthesized list in python's imaplib

I am looking for simple way to split parenthesized lists that come out of IMAP responses into Python lists or tuples. I want to go from '(BODYSTRUCTURE ("text" "plain" ("charset" "ISO-8859-1") NIL NIL "quoted-printable" 1207 50 NIL NIL NIL NIL))' to (BODYSTRUCTURE, ("text", "plain", ("charset", "ISO-8859-1"), None, None, "quoted-prin...

How can I limit the number of returned items in Perl's split?

I got a problem when I parse a complex file which include thousands of lines. I already implemented my Perl script like this days ago. my ($head, $tail) = split /=/, $line; Nearly all my source file $line style as below: constant normalLines = <type value> /* hello world */ and I can get the output $tail = /* hello world ...

Parser generation

hi.. i am doing a project on SOFWARE PLAGIARISM DETECTION..i am intended to do it with language C..for that i am supposed to create a token generator, and a parser..but i dont know where to start..any one can help me out with this.. i created a database of tokens and i separated the tokens from my program.Next thing i wanna do is to...

Asp.net MVC Razor - Custom javascript inside if block

How can I put javascript code inside if block. @{ #if DEBUG $("#User").val("JDoe"); $("#Password").val("secrect"); #endif } When I try above code I get this compiler error: Compiler Error Message: CS1056: Unexpected character '$' And if I change $ to jQuery: Compiler Error Message: CS0103: The name 'jQuery' does no...

Parse string into int32 using expressions in C#.

Hey, Basically I've wrote my own parser and I'm parsing a string into and expression and then compiling and storing to be reused later on. For (an odd) example the type of string I'm parsing is this:- if #name == 'max' and #legs > 5 and #ears > 5 then shoot() The hash parts in the string are telling my parser to look at the properti...

Parse XML with jQuery

I would need to parse this: <?xml version="1.0" encoding="utf-8"?> <blamatrixrix> <name></name> <columns number="2"> <column id="title" num="0">Title</column> <column id="content" num="1">Content</column> </columns> <rows number="7"></rows> <b>Description</c> <bDescription text here</b> <b>Some title 1</b> <b>Some text blabla for Some...

Finding a strings in a text using regular expressions with Python

Hi, I have a text, in which only <b> and </b> has been used.for example<b>abcd efg-123</b> . Can can I extract the string between these tags? also I need to extract 3 words before and after this chunk of <b>abcd efg-123</b> string. How can I do that? what would be the suitable regular expression for this? ...

What am I doing wrong in my Perl script written to parse a CSV file?

I have two scripts in which I'm experimenting with CSV_XS. In the first, I hard-coded everything: source directory, filename, and the csv delimiter I wanted to look for. The script works great. In the second, however, I try to dynamically discover as much as possible. That script seems to run, but it outputs nothing. I'm having trouble...