parsing

Replace newlines with BR tags, but only inside PRE tags

In stock PHP5, what is a good preg_replace expression for making this transformation: replace newlines with <br />, but only within <pre> blocks (Feel free to make simplifying assumptions, and ignore corner cases. For example, we can assume that tags will be one line, and not pathological things like ) Input text: <div><pre class='s...

what is the difference between a syntax and s-expressions

what is the main differences between syntax language and s-expressions language ? does using s-expressions affects compiling time (in the parsing process) or does it bring any advantage to the language ? ...

Django - Parse XML, output as HTML fragments for iFrame?

heya, I've been asked to quickly put together a small system that takes a Yahoo XML feed, parses it, and creates a HTML fragment based on it. At the moment, I'm using Django to handle the URL routing, with some Python script, and outputting a bit of HTML in a (with hardcoded dimensions as inline CSS), that can hopefully be put into an...

On the iPhone, how do i parse a html page to get all the RSS links?

in html an rss link looks somewhat like this <a class="rsslink" href="http:the_url">The feed title</a> i would like to get all links that match this description from a html page that has a list of rss feeds. anyone know of a good way to parse, with some sample code? ...

iPhone : Parse XML file with attribute

hi all, i want to parse the XML file. i am enable to parse simple XML file. but there are little complex XML file <?xml version="1.0" encoding="utf-8"?> <Level> <p id='327'> <Item> <Id>5877</Id> <Type>0</Type> <Icon>---</Icon> <Title>Btn1Item1</Title> </Item> <Item> <Id>5925</Id> <Type>0</T...

Parsing font info and converting it to System.Drawing.Font

hello all, i have a text file that contains font information like this: Arial, 12.5 ...and I need to read that info into label.Font like this: label.Font = new Font(fontNameFields[0], Single.Parse(fontNameFields[1])); ... but I always get the following error: Index was outside the bounds of the Array. Can somebody please help me w...

iPhone : parse Lengthy XML file on the Base of Key Field

hi all, i want to parse the xml File. xml File structure is following <?xml version="1.0" encoding="utf-8"?> <Level> <p id='327'> <Item> <Id>5877</Id> <Type>0</Type> <Icon>---</Icon> <Title>Btn1Item1</Title> </Item> <Item> <Id>5925</Id> <Type>0</Type> <Icon>---</Icon> <Title>Btn1I...

Index out of bounds of array error when parsing font string?

hello all, i keep getting an "Index is out of bounds of array" error on line # 574 which is: label.Font = new Font(fontNameFields[0], Single.Parse(fontNameFields[1])); ... The following text file i am parsing contains this exact information: Label "hi tyler" 23, 76 Arial,12.5 ...I can successfully parse all the other info (just not...

How to define {min,max} matches in treetop peg

With Ruby's regular expressions I could write /[0-9]{3,}/ I can't figure out how to write this in treetop other than: rule at_least_three_digit_number [0-9] [0-9] [0-9]+ end Is there a 'match [at least|most] n' rule for treetop? ...

What libraries are available for parsing c++ to extract type information

I'm looking for a way to parse c++ code to retrieve some basic information about classes. I don't actually need much information from the code itself, but I do need it to handle things like macros and templates. In short, I want to extract the "structure" of the code, what you would show in a UML diagram. For each class/struct/union/enu...

get text between <tags>in php</tags>

Currently i am using and have looked through this code http://us.php.net/manual/en/function.xml-set-element-handler.php#85970 How do i get the text between tags? i am using php5 and XML Parser ...

Haskell recursive problem, tiny parser. A few things

data Expr = Var Char | Tall Int | Sum Expr Expr | Mult Expr Expr | Neg Expr | Let Expr Expr Expr deriving(Eq, Show) That is the datatype for Expr, I have a few questions. I'm suppose to parse expressions like *(Expr,Expr) as shown in the datatype definition. However I do have some problems with "creating" a valid Expr. I use patte...

Stuck with Simple Html Dom and extracting information

I'm trying to use simple html DOM to extract everything inside a tag with the class "sitepoint". Here is my code that doesn't work: <?php include_once('simple_html_dom.php'); $html = file_get_html('examplewebsite'); $ret = $html->find('.sitepoint'); echo $ret; ?> Below is an example of one of the sitepoint tags (there are ten or so)...

What is the proper method of reading and parsing data files in C++?

What is an efficient, proper way of reading in a data file with mixed characters? For example, I have a data file that contains a mixture of data loaded from other files, 32-bit integers, characters and strings. Currently, I am using an fstream object, but it gets stopped once it hits an int32 or the end of a string. if i add random d...

Convert string to Font.

I've been having a hard time trying to get the right answers for my problem. And have spent numerous days searching online and in documentation and have found nothing. I have a Text File that contains a bunch of text. And on one of those lines inside the file will contain some Font info like this: Tahoma,12.5,Regular Note that the fon...

XStream failing when & present in the XML document

Hi , I am using xStream for serializing and de-serializing objects. But when there is "&" present for any of the tag values , xStream is failing and throwing excpetion. for e.g. this fails.. <tag>value & value</tag> Exception :- "An entity name must immediately follow..." <tag>value value</tag> this passes Is there any way to tell...

The best pratice to parse PDF forms fields with PHP5

I have PDFs with filled out form fields from a customer, which have to be parsed with PHP5 and written into a MySQL-DB. With Google I only find libraries, like Zend_Pdf, which are helpful for creating or manipulating PDFs but not for parsing for form fields. Do you know any libraries or classes for this task? ...

Haskell recursive problem, tiny parser. Negation of Expr and let expressions

data Expr = Var Char | Tall Int | Sum Expr Expr | Mult Expr Expr | Neg Expr | Let Expr Expr Expr deriving(Eq, Show) parseExpr :: String -> (Expr, String) parseExpr ('*':'(':s) = (Mult x y, s'') where (x,',':s') = parseExpr s (y,')':s'') = parseExpr s' parseExpr ('+':'(':s) = (Sum x y, s'') where (x,',':s') = par...

Joda Time bug or my mistake? (Java Joda Time dates as strings parsing)

Hi, so I was having a problem parsing a date, using the JodaTime chronology IslamicChronology so wrote a small example to demonstrate my problem. Here's the code: import org.joda.time.Chronology; import org.joda.time.format.DateTimeFormatter; import org.joda.time.format.DateTimeFormat; import org.joda.time.chrono.IslamicChronology; im...

Parse html using C

I've been a big fan of the site and frankly this is the first time I ever came across a problem that Stackoverflow didn't have the answer to. I need to grab some content from an html(xhtml valid) page. I grab the page using curl and store it in memory. I played with the idea of using regex with the PCRE library, but simply I couldn't fi...