Menu

#87 It is diffrent original of xml and converted xml.

open
nobody
5
2009-12-08
2009-12-08
Anonymous
No

Hi.
I was converted from xml to JsonObject. and then converted from JsonObject to xml.
It shown "<o> " instead of "<mi>" tag of xml.
I hope to display original of xml and converted of xml.
How method are same original of xml and converted of xml?
Thank you.

===================
original xml
<?xml version="1.0" encoding="UTF-8"?>
<MI>
<name type="string">json</name>
<bool type="boolean">true</bool>
<int type="number">1</int>
</MI>

========================
converted from XML to jsonObject string
{"name":"json","bool":true,"int":1}

=====================
converted from JsonObject to XML
<?xml version="1.0" encoding="UTF-8"?>
<o><bool type="boolean">true</bool><int type="number">1</int><name type="string">json</name></o>

=== source ===
String sourceFile = System.getProperty("user.dir") + File.separator + "src" + File.separator + "test" + File.separator + "java" + File.separator + "com" +
File.separator + "mocomsys" + File.separator + "parser" + File.separator + "xml" + File.separator + "test.xml";

JsonObjectFactory jof = new JsonObjectFactory();
InputStream is = getInputStream(sourceFile);

JSONObject jsonObject = (JSONObject) new XMLSerializer().readFromStream(is);
System.out.println(jsonObject.toString());

System.out.println("=====================");
String xml = new XMLSerializer().write(jsonObject);
System.out.println(xml);

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.