Tag Archives: parsing

Parsing malformed/incomplete/invalid XML files [duplicate]

Questions: This question already has an answer here: How to parse invalid (bad / not well-formed) XML? 2 answers Answers: You could try to use JSoup to parse the invalid XML. By definition XML should be well-formed, otherwise it’s invalid and should not be used. UPDATE – example: public static void main(String[] args) { for… Read More »

What's the clojure equivalent of Nokogiri (for xml parsing with xpath and css selectors)

Questions: I’m looking for a Clojure equivalent of Nokogiri in Ruby. Specifically, I want to be able to traverse XML using CSS and XPath selectors. Answers: First a word of caution: currently, no native Clojure lib deals correctly with XML namespaces. To traverse and transform HTML and XML using CSS-like selectors there’s is Enlive (tutorial).… Read More »

Infinite loop in CTE when parsing self-referencing table

Questions: I’m using the following Common Table Expression to parse self-referencing table. But the CTE does not work, produces and infinite loop and generates an error: Msg 530, Level 16, State 1, Line 1 The statement terminated. The maximum recursion 100 has been exhausted before statement completion. How to modify this CTE to get it… Read More »

Parsing XML namespaces?

Questions: Using JavaScript/Ajax? I’m trying to extract values from: <yweather:astronomy sunrise=”6:34 am” sunset=”8:38 pm”/> Looking for something like: var response = transport.responseXML.getElementsByTagName(“channel”); sunrise = response[0].getElementsByTagName(“yweather:astronomy”).item(0).Attributes[“sunrise”].Value; But nothing works so far. :'( Thanks. Answers: There is a special version of getElementsByTagName for namespaces: getElementsByTagNameNS. For example: var response = transport.responseXML.getElementsByTagName(“channel”); var sunrise = response[0].getElementsByTagNameNS(“[Namespace URI]”, “astronomy”)[0].getAttribute(“sunrise”);… Read More »

Eclipse Error: Error parsing …\android-22\android-wear\armeabi-v7a\devices.xml

Questions: Recently, I upgraded my android-SDK to Android M (API 22, MNC Preview). After that, every project reported errors when Eclipse was opened. The error of logcat and of a popup window says: Error: Error parsing …\sdk\system-images\android-22\android-wear\armeabi-v7a\devices.xml cvc-complex-type.2.4.d: Invalid content was found starting with element ‘d:skin’. No child element is expected at this point I… Read More »

Parsing JSON array into java.util.List with Gson

Questions: I have a JsonObject named “mapping” with the following content: { “client”: “127.0.0.1”, “servers”: [ “8.8.8.8”, “8.8.4.4”, “156.154.70.1”, “156.154.71.1” ] } I know I can get the array “servers” with: mapping.get(“servers”).getAsJsonArray() And now I want to parse that JsonArray into a java.util.List… What is the easiest way to do this? Answers: Definitely the easiest… Read More »

Parsing HTML with c#.net [duplicate]

Questions: This question already has an answer here: What is the best way to parse html in C#? [closed] 15 answers Answers: Give the HTMLAgilityPack a look into. Its a pretty decent HTML parser http://html-agility-pack.net/?z=codeplex ====== Here’s some code to get you started (requires error checking) HtmlDocument document = new HtmlDocument(); string htmlString = “<html>blabla</html>”;… Read More »

Parsing Visual Studio Solution files

Questions: How can I parse Visual Studio solution (SLN) files in .NET? I would like to write an app that merges multiple solutions into one while saving the relative build order. Answers: The .NET 4.0 version of the Microsoft.Build assembly contains a SolutionParser class in the Microsoft.Build.Construction namespace that parses Visual Studio solution files. Unfortunately… Read More »