Tagged Questions
154
votes
8answers
126k views
Best XML parser for Java [closed]
I need to read smallish (few MB at the most, UTF-8 encoded) XML files, rummage around looking at various elements and attributes, perhaps modify a few and write the XML back out again to disk ...
121
votes
18answers
70k views
Parsing query strings in Java
Java EE has ServletRequest.getParameterValues().
On non-EE platforms, URL.getQuery() simply returns a string.
What's the normal way to properly parse the query string in a URL when not on Java EE?
...
120
votes
18answers
121k views
Removing HTML from a Java String
Is there a good way to remove HTML from a Java string? A simple regex like
replaceAll("\\<.*?>","")
will work, but things like
&
wont be converted correctly and non-HTML between ...
99
votes
6answers
16k views
What are the pros and cons of the leading Java HTML parsers?
Searching SO and Google, I've found that there are a few Java HTML parsers which are consistently recommended by various parties. Unfortunately it's hard to find any information on the strengths and ...
80
votes
17answers
3k views
True-way solution in Java: parse 2 numbers from 2 strings and then return their sum
Quite a stupid question. Given the code:
public static int sum(String a, String b) /* throws? WHAT? */ {
int x = Integer.parseInt(a); // throws NumberFormatException
int y = Integer.parseInt(b); ...
78
votes
6answers
27k views
Which java YAML library should I use? [closed]
There are at least 4 YAML implementations listed at yaml.org. Which one of these (or another) would you recommend, and why?
There are two ways you could answer this question, either by voting for ...
75
votes
9answers
43k views
Best way to compare 2 XML documents in Java
I'm trying to write an automated test of an application that basically translates a custom message format into an XML message and sends it out the other end. I've got a good set of input/output ...
69
votes
8answers
33k views
SQL parser library for Java [closed]
Is there a good open-source Java library for parsing SQL statements?
If possible, it should be customizable or flexible enough to also be able to parse (or at least ignore) vendor-specific syntax ...
56
votes
4answers
53k views
In Java, how do I parse XML as a String instead of a file?
I have the following code:
DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlFile);
How can I get it to parse XML contained within a String instead of a file?
47
votes
3answers
32k views
Which Html Parser is best? [closed]
I code a lot of parsers. Up till now, I was using HtmlUnit headless browser for parsing and browser automation.
Now, I want to separate both the tasks.
As 80% of my work involves just parsing, I ...
39
votes
11answers
58k views
Java HTML Parsing [closed]
I'm working on an app which scrapes data from a website and I was wondering how I should go about getting the data. Specifically I need data contained in a number of div tags which use a specific CSS ...
35
votes
2answers
52k views
How to read XML using XPath in Java
I want to read XML data using XPath in Java, so for the information I have gathered I am not able to parse XML according to my requirement.
here is what I want to do:
Get XML file from online via ...
32
votes
7answers
29k views
What is the easiest way to parse an INI file in Java?
I am writing a drop-in replacement for a legacy application in Java. One of the requirements is that the ini files that the older application used have to be read as-is into the new Java Application. ...
31
votes
2answers
29k views
How to parse XML using the SAX parser
I'm following this tutorial.
It works great but I would like it to return an array with all the strings instead of a single string with the last element.
Any ideas how to do this?
31
votes
8answers
47k views
Json to Map
What is the best way to convert a JSON code as this:
{ "data" : { "field1" : "value1", "field2" : "value2"}}
in a Java Map in which one the keys are (field1, field2) and the values for those fields ...