清理一个 xml 文件我得到了意想不到的结果:tagsoup 已经孤立了一些属性太快关闭了父标签。它还将父标签的名称小写。
在标签汤之前:
<Objects>
<Object>
<ObjectID>240</ObjectID>
[...]
<Status>Not Ready</Status>
<Title>Some description which includes word/word, 22,000</Title>
<Url>http://example.com/withquerystring?id=240&other=1&url=http%3A%2F%2Fredirected.example.com%2F40</Url>
[...]
<Owner>
<Name>JOHN MARSHALL, MR</Name>
</Owner>
</Object>
<Object>
<ObjectID>122</ObjectID>
[...]
标签汤之后:
<Objects>
<object>
<ObjectID>240</ObjectID>
[...]
<Status>Not Ready</Status>
</object>
<Title>Some description which includes word/word, 22,000</Title>
<Url>http://example.com/withquerystring?id=240&other=1&url=http%3A%2F%2Fredirected.example.com%2F40</Url>
[...]
<Owner>
<Name>JOHN MARSHALL, MR</Name>
</Owner>
<object>
<ObjectID>122</ObjectID>
[...]
我在一个使用这个库的java项目中:
import org.ccil.cowan.tagsoup.Parser;
import org.ccil.cowan.tagsoup.XMLWriter;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
我正在使用 Java 6。
有什么线索吗?
有效 xml 文件的所需输出将是同一个文件(可能只是更改细节,而不是结构),不是吗?