parsing

Separating HTML into groups using BeautifulSoup when groups are all in the same element

Here's an example: <p class='animal'>cats</p> <p class='attribute'>they meow</p> <p class='attribute'>they have fur</p> <p class='animal'>turtles</p> <p class='attribute'>they don't make noises</p> <p class='attribute'>they have shells</p> If each animal was in a separate element I could just iterate over the elements. That would be g...

Simplepie iTunes select specific class

I'm parsing an iTunes feed, there are 3 image sizes within the feed and I'm not sure how to fetch the largest one. The iTunes Feed example: <im:image height="53">http://a1.image.53x53-50.jpg&lt;/im:image&gt; <im:image height="75">http://a1.image.75x75-65.jpg&lt;/im:image&gt; <im:image h...

boost spirit qi numeric parsing of integer and floating points

Hi, i am trying to make sense of the following result. The test case code is #include <boost/config/warning_disable.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_operator.hpp> #include <boost/spirit/include/phoenix_fusion.hpp> #include <boost/spirit/i...

using variable in xpath query..is it possible??

Could some one please tell me how do we use the text function with variable in the XPath query in c-objective for iphone. I needed the information for Engineering Library present in the xml http://www.sis.pitt.edu/~arazeez/Librarydata.xml NSString *libName = @"Engineering Library"; NSMutableString *xpathquery = [[NSMutableString a...

Very simple sexp parser

For an assignment, we had to implement something like a very basic sexp parser, such that for input like: "((a b) ((c d) e) f)" It would return: [["a", "b"], [["c", "d"], "e"], "f"] Since this was part of a larger assignment, the parser is only given valid input (matching parens &c). I came up with the following solution in Ruby: ...

Extracting *relevant* image from a web-page

I have a couple of twitter-powered news aggregation website. I have been planning to add images from articles that I find on twitter. If I download the page and extract image using <img> tag, I get a bunch of images; not all of them relevant to the article. For example, images of button, icons, ads etc are captured. How do I extract the...

Best way to create a "template interpreter" in PHP

Hi! I'm hosting a multi area solution written in PHP, and each customer has its own template in some HTML files. Now I want these users to be able to use some chunks of dynamic content, but they can't be able to use PHP. I thought something like: In the HTML file, if I put this: <ul>[menu-list]</ul> Will output something like: <ul>...

How does Python variable scoping works?

This wants me to dig deeper in Python sources, but since there are many people on SO that already done that, I would love to hear their pointers. >>> import os >>> def scope(): ... print os ... import os ... >>> scope() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in scope U...

Android rss parse - what method to use?

Hello everyone What would be the easiest way to parse an rss feed? Are there any already done easy(fast to implement) methods out there? All the posts I could find on the topic were many years old. Any new technologies out there that are worthy of attention? Or should I just make my own parser? Edit: please link to a usage method/tutori...

c# parse a string that contains conditions , key=value.

I m giving a string that contains several different combination of data. For example : string data = "(age=20&gender=male) or (city=newyork)" string data1 = "(job=engineer&gender=female)" string data2 = "(foo =1 or foo = 2) & (bar =1)" I need to parse this string and create structure out of it and i have to evaluate this to a condi...

MPEG2 parser in Java?

Hi What java librarys can I use for parsing and preview MPEG2-streams? Is JMF needed? If so, ain't JMF really quite outdated since it's most recent release was released back in 2003. ...or is the lack of librarys due to java being slow? ...

How to parse C# code to find the derived class and interfaces of a class

I am looking for an approach for finding the code between the base class identifier colon and the opening curly brace of a class that's been that's been stored into a string literal. By this I mean that I have a class public class Class : BaseClass { } That's been stored as a string string classString = "public class Class : Ba...

Parse a task list

A file contains the following: HPWAMain.exe 3876 Console 1 8,112 K hpqwmiex.exe 3900 Services 0 6,256 K WmiPrvSE.exe 3924 Services 0 8,576 K jusched.exe 3960 Console 1 5,12...

How to verify that URL is valid in Java 1.6?

My application processes URLs entered manually by users. I have discovered that some of malformed URLs (like 'http:/not-valid') result in NullPointerException thrown when connection is being opened. As I learned from this Java bug report, the issue is known and will not be fixed. The suggestion is to use java.net.URI, which is "more RFC ...

parse javascript object returned from ajax as html

Result (data) looks like this: <tr> <td> Something... </td> </tr> <div id="paging">1, 2, 3... </div> This is ajax ... dataType: "html", success: function(data) { parse data... $('#myDiv1').html(data1); $('#myDiv2').html(data2); } ... Is it possible to parse data so that data1 contains table row(s) and d...

Looking for parsing patterns for a Silverlight bbcode-to-TextBlock/Run parser

I would like to create a simple parser class for Silverlight which parses this text: [size=15]This is the header[/size] This is [i]italicized text[/i] and this is [b]bolded text[/b] and this is a hyperlink: [url]http://example.org[/url] and so is this: [url=http://example.com]Example[/url]. into this kind of code: T...

Word frequency counter

Do you know a class in Java that counts word frequency of the text, and maybe gives all the blocks of the text where the word occurs? ...

Android: can not import org.apache.harmony.xml.ExpatReader

I need to parse an UTF-8 encoded input stream, so I think the most appropriate method is to use XMLReader reader = new ExpatReader(); InputSource source = new InputSource(in); source.setEncoding(encoding.expatName); reader.parse(source); For that I need to import org.apache.harmony.xml.ExpatReader but I cannot figure ...

robots.txt parser java

hi i want to know how to parse the robots.txt in java. already any code is there? thanks in advance ...

Parse non-standard date format like "+0yyyyMMdd"

I Have Date, that comes to our system in format +0yyyyMMdd For instance 12 March,2011 is +020110312 For now it's definitely + symbol and one 0 before Date, but in future it may be more than one zeros,e.g. +000020110312 Is it possible to parse it with standard Java java.text.DateFormat.parse(String source)? Or I should write custom pa...