What is the best way to parse (get a DOM tree of) a HTML result of XmlHttpRequest in Firefox?
EDIT:
I do not have the DOM tree, I want to acquire it.
XmlHttpRequest's "responseXML" works only when the result is actual XML, so I have only responseText to work with.
The innerHTML hack doesn't seem to work with a complete HTML document (in <html</html). - turns out it works fine.
As the title says, I want to parse some Java source code in Java. I'm pretty sure there are other java libraries that already perform this, but I couldn't find any.
I am new at ipad and iphone development.
I would like to parse the table content of a PDF file.
This way i can map page number and set an internal link so i can jump to that page.
Could you please provide me a sample of code ?
I have the directory ~/fooscripts/ and inside there are foo1.txt, foo2.txt, etc etc
I have a command that takes the file foo1.txt as input and does some calculation. The output location etc is handled internally in fooprog
fooprog -user-data=foo1.txt
I would like to automate the whole thing in a bash script so that the script will parse all txt files in ~/fooscripts/ sequentially. I am a newbie in bash. Could anyone give me a hint?
I want to use the foreach container to iterate through a folder matching something like: "Filename_MMYYYY.xls". That's easy enough to do; but I can't seem to find a way to parse the MMYYYY from the filename and add it to a variable (or something) that i can use as a lookup field for my DimDate table. It seems possible with a flat file data source, but not an excel connection. I'm using Visual Studio 2005. Please help!
I am reading a .xls file and then procesing it inside and rewriting it in the end of my program. I was wondering if someone can help me to parse the dates
as my input file name is like file_1_2010_03_03.csv
and i want my outputfile to be
newfile_2010_03_03.xls
is there a way to incorporate in matlab program so i do not have to manually write the command
xlswrite('newfile_2010_03_03.xls', M);
everytime and change the dates as i input files with diff dates
like
file_2_2010_03_04.csv.
Thanks
I am trying to parse the MySQL data types returned by "DESCRIBE [TABLE]".
It returns strings like:
int(11)
float
varchar(200)
int(11) unsigned
float(6,2)
I've tried to do the job using regular expressions but it's not working.
PHP CODE:
$string = "int(11) numeric";
$regex = '/(\w+)\s*(\w+)/';
var_dump( preg_split($regex, $string) );
We have a xml column in SQL Server 2008. We need to do reporting off the data in the xml so we're going to select the xml into a flat table. The flat table has columns that correspond to various nodes in the xml.
What is the best way to do this using SSIS?
Is this a good approach? Or should we just try and write the reports directly off the xml column?
Hi, I'd like to extract the info string from an internet radio streamed over HTTP. By info string I mean the short note about the currently played song, band name etc.
Preferably I'd like to do it in python. So far I've tried opening a socket but from there I got a bunch of binary data that I could not parse...
thanks for any hints
If I want to split a list of words separated by a delimiter character, I can use
>>> 'abc,foo,bar'.split(',')
['abc', 'foo', 'bar']
But how to easily and quickly do the same thing if I also want to handle quoted-strings which can contain the delimiter character ?
In: 'abc,"a string, with a comma","another, one"'
Out: ['abc', 'a string, with a comma', 'another, one']
Related question: How can i parse a comma delimited string into a list (caveat)?
This has to be pretty simple, but I'd like to parse the current URL and execute conditional code depending on whether the user is on the /sitemap/ directory.
So for example, if the site is example.com, and if the request is example.com/sitemap/.
Then I want to execute conditional code in that case. I'm using wordpress so I'm not sure if there is a built-in function that gets this...
A pure PHP solution is fine.
Hi all, I was thinking of parsing live scores from a web site via PHP and them use them for an application I am planning to implement, so my question is is it legal to do that, parse info from web site and use it ? If I quote the source if the info ?
parse .ics Calendar file using Ical4J in android.i saw the http://ical4j.sourceforge.net/introduction.html.how to use that ical4j-1.0-rc3.jar file in my project.I need help related to this plz ?
"8,5,,1,4,7,,,,7,,1,9,3,6,,,8,6,3,9,,2,5,4,,,,,3,2,,,7,4,1,1,,4,,6,9,,5,,,,5,,,1,,6,3,,,6,5,,,,7,4,,1,7,6,,,,8,,5,,,7,1,,3,9,"
I'm doing a programming challenge where i need to parse this sequence into my sudoku script.
Need to get the above sequence into 8,5,0,1,4,7,0,0,0,7,0,1,9,3,6,0,0,8.........
I tried re but without success, help is appreciated, thanks.
All I can find information on for the URLLoader object in Actionsript 3.0 involves loading XML files, which I don't want to do. I'm trying to load in a .txt file that I want to parse, line by line with each line being delimited by a comma. Anyone know a method of doing this or a place where I can find some information on how to do this? Thanks!
I have a small website where some content is displayed within a HTML tag using AJAX. The content is simply taken from another page on the same web site. However, sometimes instead of loading the parsed PHP file, the browser displays a download box instead. I downloaded the file and this is what it looks like a text file mixed with binary or gzipped data. I can't paste the binary stuff here, but here are some of the headers:
Jul 2012 18:52:16 GMT
Server: Apache/2
X-Powered-By: PHP/5.3.10
Content-Encoding: gzip
Vary: Accept-Encoding,User-Agent
Keep-Alive: timeout=1, max=95
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
HTTP/1.1 304 Not Modified
Date: Sun, 01 Jul 2012 18:52:16 GMT
Server: Apache/2
Connection: Keep-Alive
Keep-Alive: timeout=1, max=93
ETag: "2fc857-409-4c39691c59b40"
HTTP/1.1 304 Not Modified
Date: Sun, 01 Jul 2012 18:52:16 GMT
Server: Apache/2
Connection: Keep-Alive
Keep-Alive: timeout=1, max=92
ETag: "2fc854-3e5-4c39691b65900"
HTTP/1.1 304 Not Modified
Date: Sun, 01 Jul 2012 18:52:16 GMT
Server: Apache/2
Connection: Keep-Alive
Keep-Alive: timeout=1, max=91
ETag: "2fc847-3e3-4c3969197d480"
and large blocks of stuff like this:
µàl]&BaËÜk#ìÏ
I'm developing a script using the ruby Treetop library and having issues working with its syntax for regex's. First off, many regular expressions that work in other settings dont work the same in treetop.
This is my grammar: (myline.treetop)
grammar MyLine
rule line
string whitespace condition
end
rule string
[\S]*
end
rule whitespace
[\s]*
end
rule condition
"new" / "old" / "used"
end
end
This is my usage: (usage.rb)
require 'rubygems'
require 'treetop'
require 'polyglot'
require 'myline'
parser = MyLineParser.new
p parser.parse("randomstring new")
This should find the word new for sure and it does! Now I wont to extend it so that it can find new if the input string becomes "randomstring anotherstring new yetanother andanother"
and possibly have any number of strings followed by whitespace (tab included) before and after the regex for rule condition. In other words, if I pass it any sentence with the word "new" etc in it, it should be able to match it.
So let's say I change my grammar to:
rule line
string whitespace condition whitespace string
end
Then, it should be able to find a match for:
p parser.parse("randomstring new anotherstring")
So, what do I have to do to allow the string whitespace to be repeated before and after condition? If I try to write this:
rule line
(string whitespace)* condition (whitespace string)*
end
, it goes in an infinite loop. If i replace the above () with [], it returns nil
In general, regex's return a match when i use the above, but treetop regex's dont.
Does anyone have any tips/points on how to go about this? Plus, since there isn't much documentation for treetop and the examples are either too trivial or too complex, is there anyone who knows a more thorough documentation/guide for treetop?
I'm working in c# doing some OCR work and have extracted the text I need to work with. Now I need to parse a line using Regular Expressions.
string checkNum;
string routingNum;
string accountNum;
Regex regEx = new Regex(@"\u9288\d+\u9288");
Match match = regEx.Match(numbers);
if (match.Success)
checkNum = match.Value.Remove(0, 1).Remove(match.Value.Length - 1, 1);
regEx = new Regex(@"\u9286\d{9}\u9286");
match = regEx.Match(numbers);
if(match.Success)
routingNum = match.Value.Remove(0, 1).Remove(match.Value.Length - 1, 1);
regEx = new Regex(@"\d{10}\u9288");
match = regEx.Match(numbers);
if (match.Success)
accountNum = match.Value.Remove(match.Value.Length - 1, 1);
The problem is that the string contains the necessary unicode characters when I do a .ToCharArray() and inspect the contents of the string, but it never seems to recognize the unicode characters when I parse the string looking for them. I thought strings in C# were unicode by default.
XAML is essentially a subset of XML. One of the main benefits of basing XAML on XML is said to be that it can be parsed with existing tools. And it can, to a large degree, although the (syntactically non-trivial) attribute values will stay in text form and require further parsing.
There are two major alternatives to describing a GUI in an XML-derived language. One is to do what WinForms did, and describe it in real code. There are numerous problems with this, though it’s not completely advantage-free (a question to compare XAML to this approach). The other major alternative is to design a completely new syntax specifically tailored for the task at hand. This is generally known as a domain-specific language.
So, in hindsight, and as a lesson for the future generations, was it a good idea to base XAML on XML, or would it have been better as a custom-designed domain-specific language? If we were designing an even better UI framework, should we pick XML or a custom DSL?
Since it’s much easier to think positively about the status quo, especially one that is quite liked by the community, I’ll give some example reasons for why building on top of XML might be considered a mistake.
Basing a language off XML has one thing going for it: it’s much easier to parse (the core parser is already available), requires much, much less design work, and alternative parsers are also much easier to write for 3rd party developers.
But the resulting language can be unsatisfying in various ways. It is rather verbose. If you change the type of something, you need to change it in the closing tag. It has very poor support for comments; it’s impossible to comment out an attribute. There are limitations placed on the content of attributes by XML. The markup extensions have to be built "on top" of the XML syntax, not integrated deeply and nicely into it. And, my personal favourite, if you set something via an attribute, you use completely different syntax than if you set the exact same thing as a content property.
It’s also said that since everyone knows XML, XAML requires less learning. Strictly speaking this is true, but learning the syntax is a tiny fraction of the time spent learning a new UI framework; it’s the framework’s concepts that make the curve steep. Besides, the idiosyncracies of an XML-based language might actually add to the "needs learning" basket.
Are these disadvantages outweighted by the ease of parsing? Should the next cool framework continue the tradition, or invest the time to design an awesome DSL that can’t be parsed by existing tools and whose syntax needs to be learned by everyone?
P.S. Not everyone confuses XAML and WPF, but some do. XAML is the XML-like thing. WPF is the framework with support for bindings, theming, hardware acceleration and a whole lot of other cool stuff.
I am running Tomcat 7 and am deploying a bunch of applications delivered to me by a third party as WAR files.
I'd like to force some of those apps to always use SSL. (All the "SSL" apps are in one service; other apps outside this discussion are in another service.)
I've figured out how to use conf\web.xml to redirect apps from HTTP to HTTPS, but that applies to all applications hosted by Tomcat. I've also figured out how to put web.xml in an unpacked app's web-inf directory; that does the trick for that specific app, but runs the risk of being overwritten if our vendor gives us a new war file to deploy.
I've also tried placing the web.xml file in various places under conf\service\host, or under appbase, but none seem to work.
Is it possible to redirect some apps to SSL without forcing all apps to redirect, or to put the web.xml file inside the extracted WAR file?
Here's my server.xml:
<Service name="secure">
<Connector port="80" connectionTimeout="20000" redirectPort="443"
URIEncoding="UTF-8" enableLookups="false" compression="on"
protocol="org.apache.coyote.http11.Http11Protocol"
compressableMimeType="text/html,text/xml,text/plain,text/javascript,application/json,text/css"/>
<Connector port="443"
URIEncoding="UTF-8" enableLookups="false" compression="on"
protocol="org.apache.coyote.http11.Http11Protocol"
compressableMimeType="text/html,text/xml,text/plain,text/javascript,application/json,text/css"
scheme="https" secure="true" SSLEnabled="true" sslProtocol="TLS"
keystoreFile="..." keystorePass="..." keystoreType="PKCS12"
truststoreFile="..." truststorePass="..." truststoreType="JKS"
clientAuth="false"
ciphers="SSL_RSA_WITH_RC4_128_MD5,SSL_RSA_WITH_RC4_128_SHA,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_DSS_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_AES_128_CBC_SHA"/>
<Engine name="secure" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<Host name="localhost" appBase="webapps" unpackWARs="false"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
<Service name="mutual-secure">
...
</Service>
The content of the web.xml files I'm playing with is:
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<security-constraint>
<web-resource-collection>
<web-resource-name>All applications</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<description>Redirect all requests to HTTPS</description>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
</web-app>
(For conf\web.xml the security-constraint is added just before the end of the existing file, rather than create a new file.)
My webapps directory (currently) contains only the WAR files.