Skip to main content

Posts

Parsing XML with namespace in Java

Introduction Yesterday, again, I needed parser a XML stream using Java. Then I went to Google try to find a exemple code. Because I needed the value of two specific fields, TAGs, I decided use XPATH to get directly this values. How ever, I needed do several tried until get a result. Keywords JAVA, XML, NAMESPACE, XML PARSE; Article I will show how to read XML without namespace and after we will read a XML streams with namespaces. This is the first XML that I have used in this example without namespaces <?xml version="1.0" encoding="UTF-8"?> <root>   <head>     <title>My Book</title>   </head>   <bookreview>     <title>This is a book about special girls</title>     <girls>       <girl>         <name>Mata Hari</name>       </girl>       <girl>     ...

URL Parameters & JavaScript

Diogenes Painting by Jean Leon Gerome T oday I was in need of a simple solution to get targeted parameters to a HTML page I'm in a platform that only accepts a page as home page HTML. In my case my login page. I needed that if the login had not success, then one message would be passed to this same page be reloaded,  reading and showing  the message. I did not want to create a second page that is always overlooked when changing the layout or css. After a little search I wrote the follow code: to use, create a HTML file like: parametro.html open with your browser, type something like: file:///yourfolder/parametro.html?param=Hello World&param2=21/12/1966 <!DOCTYPE HTML> <HTML LANG="pt-br"> <HEAD> <SCRIPT> /**  * Example of how to read the parameters of   * a URL when loading a page using javascript  * @author Nivio dos Santos  * @version 1.0  */ /**  * Creating namespace in order to av...