Parsing a document

User 6af971fe5d

31-03-2008 16:01:46

I'm trying to take a string and read it into an MDocument using parseMRV() and finding no success. Here's my string - what's wrong with it?





<MDocument> <MChemicalStruct> <molecule molID="m1"> <atomArray atomID="a1 a2 a3 a4 a5 a6" elementType="C C C C C C" x2="-10.324999809265137 -11.658669150313395 -11.658669150313395 -10.324999809265137 -8.991330468216878 -8.991330468216878" y2="9.531700674941323 8.761683734382283 7.221649853264202 6.451632912705161 7.221649853264202 8.761683734382283"></atomArray> <bondArray> <bond atomRefs2="a1 a2" order="1"></bond> <bond atomRefs2="a1 a6" order="2"></bond> <bond atomRefs2="a2 a3" order="2"></bond> <bond atomRefs2="a3 a4" order="1"></bond> <bond atomRefs2="a4 a5" order="2"></bond> <bond atomRefs2="a5 a6" order="1"></bond> </bondArray> </molecule>


</MChemicalStruct> </MDocument>

User 6af971fe5d

31-03-2008 16:24:40

Nevermind...





Apparently, there must be newlines in the content in order for it to parse properly...

ChemAxon 7c2d26e5cf

01-04-2008 12:51:18

Can you confirm that you use Marvin 4.1.x?

User 6af971fe5d

01-04-2008 13:34:59

Looks like 4.1.6...





I did a quick and dirty addition of newlines after tags and that worked so I ended up using JDOM to read in the XML and write it back out with the newline option turned on and then MDocument.parseMRV() read it in without problems.

ChemAxon 7c2d26e5cf

01-04-2008 16:36:35

Meanwhile, I have found a bug in current Marvin (5.0.2_1):MDocument.parseMRV(String) throws NullPointerException.


I fixed it in this moment.


Marvin 5.0.x accepts also one line MRV sources (without '\n'-s).


In new Marvin, the CML root tag is obligate but it also accept old MRV-s for backward compatibility.


Code:
<?xml version="1.0" ?>


<cml>


<MDocument>


...


</MDocument>


...


</cml>