Java for Testers – Read and Print XML II

Purpose

Next we merge the two main class programs for the former post into a single application. After execution of this package paths, xml filenames and accompanying content are printed to our NetBeans console.

Preparation

Earlier I recommended Java beginners to save the main programs in their Hello World project. It’s time to leave this one project approach. As a Java-for-testers beginners you better start a new project for every single problem you encounter. You can always copy the core of your solution to the package where you need it not ‘contaminating’ the project you are actually working on with maybe useless code.  Which allows me referring Occam’s razor blade. Today his medieval approach is more useful to us as agile testers in stripping the ‘borrowed’ code than for instance ISQTB. Applying his blade probably gives you the leanest code you need to perform your job. Analysing xml files for example.

Continue reading “Java for Testers – Read and Print XML II”

Java for Testers – Read and Print XML file

Purpose

In my former post I provided the java code to search for xml-files in our logs- directory and write these filenames including  their pathname to a text file named “FilteredLogFileList.txt” in the project directory. I also described how to create the logs-folder and fill it with files.

I use this setup as my starting point for the next step. Here we take a single well formatted xml-file and present it’s content in the NetBeans console. This is easier than you think. Java knows a lot of libraries to perform specific tasks and reading xml-files is one of them. If you used dummyXMLs you can use dummy2.xml in the rest of this post.

Continue reading “Java for Testers – Read and Print XML file”