parsing

What is the fastest way to remove nodes from a large XML file using .net

I am working working with very large XML files (100s of MBs). The tree is fairly simple <items> <item> <column1>ABC</column1> <column2>DEF</column2> </item> <item> <column1>GHI</column1> <column2>KLM</column2> </item> </items> I need to parse this document, and remove some <item> elements. So far, the best peer...

What is the most efficient way to separate the int from this string?

I have a string in this format: "ABC_123_" I want to end up with and integer variable that is just the number portion of the string. What is the most efficient way to accomplish that in C#? ...

XStream: Collapsing XML hierarchy as I parse

I have an XML document (generated by Adobe XFA forms), that contains data like the following: <Position> <PositionBorder> <Title/> <StartDate/> <EndDate/> </PositionBorder> </Position> Since this file is defined elsewhere, I am not at liberty to change the format of the XML that I get. In my Java code, I cr...

read a specific line from a txt file in VB .net

Hi, In VB.net I'm trying to read in a specific line from a file. An example of the line in the txt file is: [PATH] = "/this/directory/run.exe" Now I understand how to open the file for reading and writing in VB, but I need to parse out the path in the "" (quotation marks). Any help would be greatly appreciated!! --Adam ...

PHP_ParserGenerator - bug in grammar or in the parser generator?

I'm trying to create a parser for a simple language with the lemon port to PHP, and it works, almost. The following grammar: %name SP_ %declare_class { class SpecParser } %token_prefix SP_ %include_class { public $retvalue = '<todo: error handling>'; public function singleKey($elem) { end($elem); return key($elem); } } %pa...

Markdown blockquote parsing with ANTLR

This has been something that's been bothering me for a while. How does one go about parsing the following text into the HTML below using ANTLR? I can't seem to wrap my head around this at all. Any Ideas? Markdown: > first line > second line > blockquote> <p>first line second line</p> <blockquote> <p>nested quote</p> </b...

EDI Flat File parsing with C#?

Initially I was thinking to use SSIS to parse an EDI file, however I've seen a few manual EDI parsers (field mapping), and would like to use automate this functionality in C#. EDI file - ie: http://www.altova.com/images/shots/edi_source3.gif Tips appreciated. Thanks. ...

How would I remove all spaces between single quotes skipping escaped quotes in PHP

Exactly as the title asks: How would I remove all unnecessary spaces between single quotes skipping escaped quotes in PHP? I am looking for a fast implementation to pre-prep for parsing. I would prefer not to use regex if it would be slower than using a simple loop. (The double quotes below are for display purposes only) examples wo...

Get all Attributes from a HTML element with Javascript/jQuery

Hi I want to put all attributes in a Html element into an array: like i have a jQuery Object, whichs html looks like this: <span name="test" message="test2"></span> now one way is to use the xml parser described here, but then i need to know how to get the html code of my object. the other way is to make it with jquery, but how? the...

Manually emit a token with ANTLR

Hello folks, I'm having a bit of trouble manually emitting a token with a lexer rule in ANTLR. I know that the emit() function needs to be used but there seems to be a distinct lack of documentation about this. Does anybody have a good example of how to do this? The ANTLR book gives a good example of how you need to do this to parse ...

vb .net overwrite a specific line in a text file

Following hot on the heels of my question about how to read from a line in vb .net, I need to do the following: change the line in a text file [Path] = "c:\this\certain\path\" with this line [Path] = "c:\that\other\newer\path\" these paths will most certainly be different lengths, so I need to either replace what's in the quotes ...

Android: Parsing XML DOM parser. Converting childnodes to string.

Hello, Again a question. This time I'm parsing XML messages I receive from a server. Someone thought to be smart and decided to place HTML pages in a XML message. Now I'm kind of facing problems because I want to extract that HTML page as a string from this XML message. Ok this is the XML message I'm parsing: <AmigoRequest> <From></Fr...

Using Python struct.unpack with 1-byte variables

How can I use struct.unpack() or some other function available in Python to easily convert one byte variable to a Python integer? Right now, it is done in a rather lame way: file = open("telemetry.dat", "rb").read() magic = file[0] int(binascii.hexlify(magic), 16) Is there another? ...

Parsing XML not working, why?

- (void)parserDidStartDocument:(NSXMLParser *)parser { nestedChannels = [ [ NSMutableArray alloc ] init ]; .... } - (void)parser:(NSXMLParser *)parser didStartElement.... { Channel *channel = [ [ Channel alloc ] init ]; [ nestedChannels addObject:channel ]; .... } - (void)parser:(NSXMLParser *)parser foundCharacters...

fastest way to compare strings in python

I'm writing a script in Python that will allow the user to input a string, which will be a command that instructs the script to perform a specific action. For the sake of argument, I'll say my command list is: lock read write request log Now, I want the user to be able to enter the word "log" and it will peform a specific action, whi...

Importing CSV from a variable instead of file?

Hi Folks, I have a command that formats it's output in the form of CSV. I have a list of machine this command will run against using a foreach loop. in the below example $serverlist is automatically generated with an AD Query. foreach ($server in $serverlist) { $outputlist = mycommand } what I would like to do is somehow end up wit...

unable to extract image url in xml parsing in iphone

Hello, I am quite new to the iphone development, I am using xml parsing to parse contents of a feed this feed contains this line <enclosure url="http://www.abc.com/wp-content/uploads/2010/01/abc.jpg" length="64690" type="image/jpg" /> no I want to extract http://www.abc.com/wp-content/uploads/2010/01/abc.jpg XML structure is like t...

Analysing a shell script

This would be part of a reverse-engineering project. To determine and document what a shell script (ksh, bash, sh) does, it is comfortable, if you have information about what other programs/scripts it calls. How could one automate this task? Do you know any program or framework that can parse a shell script? This way for instance, I co...

Bit aligned reading and writing from binary files

I would like to read and write n bits from/to binary files. For example, read the next n bits into an integer or the next n bits to a char. I need the data to be bit aligned and not byte aligned. Are there C++ libraries that allow me to do that? When I use ostream/istream, I seem to be restricted to using byte aligned data. This is no...

Using C/C++ to efficiently de-serialize a string comprised of floats, tokens and blank lines

I have large strings that resemble the following... some_text_token 24.325973 -20.638823 -1.964366 0.753947 -1.290811 -3.547422 0.813014 -3.547227 0.472015 3.723311 -0.719116 3.676793 other_text_token 24.325973 20.638823 -1.964366 0.753947 -1.290811 -3.547422 -1.996611 -2.877422 0.813014 -3.547227 1.63236...