上个月经济危机的时候抽个下午写了写,挣了点生活补贴o(╯□╰)o。要求是这样的:In this assignment, you will create a simple XML parser designed to process simple XML files that have no attributes.
The program should use command line arguments to pass the XML file name.
./xmlparser test.xml
The output should be a text file with the same name but .txt (in this example test.txt). This text file should list the root element of the document and all children elements in the document tree.

一个简单的例子:

XML example

 

没有采用严格转化成树形结构的方式做,直接模拟开搞。程序如下: