How do i write a XML file using Java?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I have a method that reads a text file and counts the most frequently occuring words
Now i want to write them into xml format and for that im searching for good tutorials aimed at beginner level
for example if the text file has the following;
for-3 now-10 alice-221 wonderland-12
I would then want to write a method that codes the above roughly as;
<frequentlyoccuringwords>
<word occurence>count</word occurence>
<frequentlyoccuringwords>
Do suggest something meaningful
Still a beginner at crafting quality coding but have the zeal to learn more. Your help would be appreciated.
My Blog on Learning Analytics
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Or are you looking for something more complicated?
[OCP 21 book] | [OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I want it in proper XML format as referred in my Original post
Still a beginner at crafting quality coding but have the zeal to learn more. Your help would be appreciated.
My Blog on Learning Analytics
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
However could you refer to me a book too that is like Dietel, plain and simple and targets Java and XML
Still a beginner at crafting quality coding but have the zeal to learn more. Your help would be appreciated.
My Blog on Learning Analytics
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
In the previous example I have just created a file with .xml extension in C:/ and put the string (which contains count variable) in that file.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What i'm trying to achieve here is a lil bit different.
Let' say there is a file containing the following text
" Humpty dumpty sat on a wall
Humpty fell down
Dumpty laughed aloud"
The java program is supposed to read the above text file and create groups of words occuring multiple times, so it would be as "humpty-02", "dumpty-01", "wall-01" and so forth...
Now i have managed to write the code for the above text classification.
What now i want to do is, something like this ...
<frequentlyoccuring words>
<humpty> 02</humpty>
<dumpty>01</dumpty>
<wall>01</wall>
</frequentlyoccuring words>
This second part of converting it into well formed XML is what i'm stuck and stumped with....
Still a beginner at crafting quality coding but have the zeal to learn more. Your help would be appreciated.
My Blog on Learning Analytics
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The output will be the following :
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
That's brilliant.
I wish i could code so promptly, maybe not now but very soon
Till, then; Cheers.
Still a beginner at crafting quality coding but have the zeal to learn more. Your help would be appreciated.
My Blog on Learning Analytics
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
So my next exercise in this code is to use DocumentBuilderFactory methods of the javax.xml package library because your code uses append method of StringBuffer class .. its fine but i would like to better it by using the xml library package ... so that's the next goal; to achieve. But still, thanks for the idea.
Also there is one flaw in my code, I'm using a predefined string to search for in the ArrayList, but im sure i will figure out how to fix it.
Cheers.
Still a beginner at crafting quality coding but have the zeal to learn more. Your help would be appreciated.
My Blog on Learning Analytics
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Mohamed Sanaulla wrote:You can have a look at the support provided by the DOM parser in creating XML files. Or there's another approach by using XMLStreamWriter
Thanks for the suggestion, however i consider myself to be a begineer when it comes to integrating XML with java.
Could you suggest a good book that tackles this subject at the beginner level?
Still a beginner at crafting quality coding but have the zeal to learn more. Your help would be appreciated.
My Blog on Learning Analytics
| You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |








