我尝试在我的简易项目中使用XOM生成xml文件。
我按照说明Installing XOM。
我在我的项目中添加了jar,它完美无缺。但我无法运行他们简单的测试示例:
To check your download you can run one of the sample programs found in the xom-samples.jar file. For instance, nu.xom.samples.PrettyPrinter class formats an XML document by inserting and removing white space around element boundaries. In Java 1.4 and later you can run it from the command line like this: $ java -classpath xom-samples.jar:xom-1.1.jar nu.xom.samples.PrettyPrinter filename.xml
这是它的外观:
nazar@nazar-desctop:~/Downloads/XOM$ ls -lg
total 7032
drwxrwxrwx 5 nazar 4096 Dec 24 15:12 apidocs
drwxrwxrwx 3 nazar 4096 Apr 24 2013 bin
-rwxrwxrwx 1 nazar 39168 Apr 25 2013 build.xml
drwxrwxrwx 3 nazar 4096 Feb 6 2011 classes15
drwxrwxrwx 10 nazar 4096 Dec 24 15:12 data
drwxrwxrwx 3 nazar 4096 Feb 6 2011 fatsrc
-rwxrwxrwx 1 nazar 26430 Feb 6 2011 lgpl.txt
drwxrwxrwx 2 nazar 4096 Dec 24 15:12 lib
-rwxrwxrwx 1 nazar 1064 Feb 6 2011 LICENSE.txt
-rwxrwxrwx 1 nazar 4340 May 8 2005 mondial.dtd
-rwxrwxrwx 1 nazar 1226484 Jun 29 2005 mondial.xml
-rwxrwxrwx 1 nazar 1662 Feb 6 2011 overview.html
-rwxrwxrwx 1 nazar 1952 Feb 6 2011 project2.xml
-rwxrwxrwx 1 nazar 1616 Feb 6 2011 project.xml
-rwxrwxrwx 1 nazar 3067 Apr 24 2013 README.txt
drwxrwxrwx 3 nazar 4096 Feb 6 2011 src
drwxrwxrwx 3 nazar 4096 Feb 6 2011 src15
-rwxrwxrwx 1 nazar 44177 Apr 24 2013 Todo.txt
-rwxrwxrwx 1 nazar 5128917 Oct 12 2005 wsPerform_hoschek.pdf
drwxrwxrwx 2 nazar 4096 Dec 24 15:12 www
-rwxrwxrwx 1 nazar 313253 May 25 2013 xom-1.2.10.jar
-rwxrwxrwx 1 nazar 26623 Feb 6 2011 xom.graffle
-rwxrwxrwx 1 nazar 185519 May 27 2003 XOM.pdf
-rwxrwxrwx 1 nazar 125864 May 25 2013 xom-samples.jar
nazar@nazar-desctop:~/Downloads/XOM$ java -classpath xom-samples.jar:xom-1.2.10.jar nu.xom.samples.PrettyPrinter filename.xml
Due to an IOException, the parser could not check filename.xml
解决方案:
在同一目录下创建items.xml
:
<?xml version="1.0" encoding="ISO-8859-1"?>
<items xml:base="file:///home/nazar/Downloads/XOM/items.xml">
<item>
<product>
<description>Ink Jet Refill Kit</description>
<price>29.95</price>
</product>
<quantity>8</quantity>
</item>
<item>
<product>
<description>4-port Mini Hub</description>
<price>19.95</price>
</product>
<quantity>4</quantity>
</item>
</items>
为什么会这样?
有什么建议吗?
答案 0 :(得分:0)
filename.xml
在此目录中根本不存在。替换为另一个XML文件的路径。 IOException
告诉您输入中存在错误。这是因为Java无法找到文件