How do I download the source code of a web page and then stick it in SAX parser as a whole?
I just want to download the source as a string. Then stick that XML (which is currently a string) into a parser. ...
I just want to download the source as a string. Then stick that XML (which is currently a string) into a parser. ...
public static void parseit(String thexml){ SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser saxParser; try { saxParser = factory.newSAXParser(); DefaultHandler handler = new DefaultHandler() { public void startElement(String uri, String localName, String qName, Attributes att...
I'd like to parse formatted basic values and a few custom strings from a TextReader - essentially like scanf allows. My input might not have line-breaks, so ReadLine+Regex isn't an option. I could use some other way of chunking text input; but the problem is that I don't know the delimiter at compile time (so that's tricky), and that ...
Hi Hthere, is there a possibiliy to to edit c# code (in a file) via a parser or something? I want to add a new property /method/ interface to the class automatically. Does something already exist? thanks, el ...
I'm thinking about adding some sort of reflection capabilities to some C++ classes ( so that I wouldn't have to use RTTI ): getting names of methods, declared fields, class name ... this sort of stuff. I was thinking about parsing existing source files, get a list of declared fields & methods, and rewrite each source file, adding this s...
I'm working on a tool that will perform some simple transformations on programs (like extract method). To do this, I will have to perform the first few steps of compilation (tokenizing, parsing and possibly building a symbol table). I'm going to start with C and then hopefully extend this out to support multiple languages. My question i...
I'm doing a simple exercise from a book and I'm a little bit confused with how the java function parseInt works. I have read a line from an input file, used the StringTokenizer to split it and now I want to parse each part as an integer. I have checked in the watch window that the input of the parseInt function is indeed a string which ...
I'm trying to parse (in Ruby) what's effectively the UNIX passwd file-format: comma delimiters, with an escape character \ such that anything escaped should be considered literally. I'm trying to use a regular expression for this, but I'm coming up short — even when using Oniguruma for lookahead/lookbehind assertions. Essentially, all o...
public static void parseProfilesJson(String the_json){ try { JSONObject myjson = new JSONObject(the_json); JSONArray nameArray = myjson.names(); JSONArray valArray = myjson.toJSONArray(nameArray); for(int i=0;i<valArray.length();i++) { String p = nameArra...
i want to parse the addresses from google gecoding api and store it as: address city state zipcode country some places has full address from google map and some just half, how can i know which part of the address is city, state or country? or just zipcode? it would be helpful if some expert pointed out some help here. ...
Hi all, I'm looking for a bit of help with a regex in python and google is failing me. Basically I'm searching some html and there is a certain type of table I'm searching for, specifically any table that includes a background tag in it (i.e. BGCOLOR). Some tables have this tag and some do not. Could someone help me out with how to wr...
Hi there, In Lex/Flex is there a way to get the position in the character stream (from the start of the file) that a token appears at? Kind of like yylineno except that it returns the character position as an integer? If not, what's the best way to get at this? Do I need to keep my own counter? Thanks! ...
I have a relatively simple lex/flex file and have been running it with flex's debug flag to make sure it's tokenizing properly. Unfortunately, I'm always running into one of two problems - either the program the flex generates stops just gives up silently after a couple of tokens, or the rule I'm using to recognize characters and strings...
Hello What is the best way to do the following in Java. I have two input strings this is a good example with 234 songs this is %%type%% example with %%number%% songs I need to extract type and number from the string. Answer in this case is type="a good" and number="234" Thanks ...
Hi all, I am in the phase of scanning to build a compiler. I wonder if I should read entire file content before processing? I think it should be better since my compiler may need to do some optimization later (so I dont need to reread the file). But what if the input program is kinda big, it could take lots of memory to hold the file co...
I had to write the following function to fail gracefully when trying to parse a string to an integer. I would imagine Python has something built in to do this, but I can't find it. If not, is there a more Pythonic way of doing this that doesn't require a separate function? def try_parse_int(s, base=10, val=None): try: return int(s...
As the title. I tested NSScanner, but it passed some strange strings. (ex :123aaa). Is there any way to convert string<->number strictly? ...
I wrote a custom XML reader because I needed something that would not read ahead from the source stream. I wanted the ability to have an object read its data from the stream without negatively affecting the stream for the parent object. That way, the stream can be passed down the object tree. It's a minimal implementation, meant only ...
I'm looking at integrating multipart form-data parsing in a web server module so that I can relieve backend web applications (often written in dynamic languages) from parsing the multipart data themselves. The multipart grammar (RFC 2046) looks non-trivial and if I implement it by hand a lot of things can go wrong. Is there already a goo...
Hello, I have the following code to parse a String variable called str. NumberFormat formatter = NumberFormat.getInstance(); Number number = formatter.parse(str); I want to catch the Exception thrown when str is not a number just to validate it. The problem I have is that it does't always throws the ParseException expected. When the ...