How-to articles, tricks, and solutions about PARSING

"Content is not allowed in prolog" when parsing perfectly valid XML on GAE

The "Content is not allowed in prolog" error typically occurs when you try to parse an XML document that contains characters before the XML prolog (the <?xml ...?> declaration).

Convert JSON to Map

You can use the Gson library to convert a JSON string to a Map in Java.

How do I parse a string to a float or int?

To parse a string to a float or int in Python, you can use the float() and int() functions, respectively.

How to convert jsonString to JSONObject in Java

To convert a JSON string to a JSONObject in Java, you can use the JSONObject constructor that takes a String as an argument, like this:

How to convert/parse from String to char in java?

In Java, you can convert a string to a character using the charAt() method of the String class. This method takes an index as an argument and returns the character at that index.

How to parse JSON in Java

To parse a JSON string in Java, you can use the org.json library. This library provides a simple and easy-to-use interface for parsing and manipulating JSON data in Java.

How to Parse XML with PHP

XML (Extensible Markup Language) is used to store and transport data. Learn how to accurately parse XML with PHP simpleXML library in this simple snippet.

How to read json file into java with simple JSON library

To read a JSON file into Java using the Simple JSON library, you can use the JSONObject class and the JSONArray class.

How to read XML using XPath in Java

To read XML using XPath in Java, you can use the javax.xml.xpath package.

Java format yyyy-MM-dd'T'HH:mm:ss.SSSz to yyyy-mm-dd HH:mm:ss

To convert a date in the format yyyy-MM-dd'T'HH:mm:ss.SSSz to the format yyyy-mm-dd HH:mm:ss, you can use the SimpleDateFormat class in Java.

Java: parse int value from a char

To parse an integer value from a char in Java, you can use the Character.getNumericValue() method.

Parsing JSON string in Java

To parse a JSON string in Java, you can use the JSONObject class from the org.json package.

PHP: Best way to extract text within parenthesis?

There are a few different ways to extract text within parentheses in PHP, depending on the specific requirements of your use case.

Remove HTML tags from a String

To remove HTML tags from a string, you can use a regular expression to match and replace the tags with an empty string.

syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

This error message is typically encountered when there is a problem with the syntax of a string in PHP.

Why can't Python parse this JSON data?

Without a specific code snippet and the JSON data that is causing issues, it is difficult to determine why Python is unable to parse the data.