Given the following graphical drawing for dimethylamine:
Let us look some sample CDX and CDXML files that can represent this structure. Note that these are not the exact files as produced by ChemDraw. When ChemDraw writes files, it stores a lot of information so that it can preserve every single state in the drawing environment exactly. In many case, much of that information can be extraneous, particularly if you are interested only in the chemical content of a file.
These files can be compared to those in the next example to see the sorts of extraneous information that ChemDraw writes. As you will see, most of it is related to graphical attributes such as bond width, or related to logical attributes such as a bounding box. The examples immediately below are good examples to study if you want to create a program that writes CDX or CDXML files; the ones in the next example are good ones to study if you want to write a program that reads CDX or CDXML files as produced by ChemDraw.
Note how little is actually specified in these files. Default values (such as treating a node as an unlabeled carbon atom unless otherwise specified) take care of most of the most-common cases. As an aside, these files could be made even shorter by omitting the coordinates of the three atoms. ChemDraw would generate reasonable coordinates automatically, but there's not much chance that ChemDraw's autogenerated coordinates would exactly match the originals.
These files can be represented schematically like this:
Objects are circled and the properties they contain radiate from them. Object nesting is represented by hierarchy. The one and only fragment (ID 8) object holds the entire molecule. Nodes 4 and 6 are the two carbon atoms; Node 5 is the nitrogen.
56 6A 43 44 30 31 30 30 04 03 02 01 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 01 80 01 00
00 00 03 80 08 00 00 00 04 80 05 00 00 00 00 02
08 00 00 40 A4 00 00 80 94 00 02 04 02 00 07 00
00 00 04 80 06 00 00 00 00 02 08 00 BA 03 AC 00
4F 7A B1 00 00 00 05 80 02 00 00 00 04 06 04 00
0C 00 00 00 05 06 04 00 0D 00 00 00 00 00 04 80
04 00 00 00 00 02 08 00 BA 03 AC 00 B0 85 77 00
00 00 05 80 03 00 00 00 04 06 04 00 0C 00 00 00
05 06 04 00 0F 00 00 00 00 00 00 00 00 00 00 00
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE CDXML SYSTEM "http://www.camsoft.com/xml/cdxml.dtd" >
<CDXML
><page
><fragment
><n
id="5"
p="148.5 164.25"
Element="7"
></n><n
id="6"
p="177.48 172.01"
/><n
id="4"
p="119.52 172.01"
/><b
B="5"
E="6"
/><b
B="5"
E="4"
/></fragment></page></CDXML>
Here is a side-by-side listing of the two file formats to highlight how similar they are. The CDX file is byte-for-byte identical to the original listing above.
The CDXML file has been rearranged to match the order of the CDX file. Since objects and fragments can be listed in any order, this reordering produces a valid CDXML file in its own right.
56 6A 43 44 30 31 30 30 04 03 02 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE CDXML SYSTEM "http://www.camsoft.com/ xml/cdxml.dtd" > <CDXML |
|
01 80 | <page | Start of Page object |
01 00 00 00 | id="1" | omitted from CDXML because it is optional |
03 80 | <fragment | Start of Fragment object |
08 00 00 00 | id="8" | omitted from CDXML because it is optional |
04 80 | <n | Start of Node object |
05 00 00 00 | id="5" | |
00 02 08 00 00 40 A4 00 00 80 94 00 |
p="148.5 164.25" | |
02 04 02 00 07 00 | Element="7" | |
00 00 | > | End of Node object |
04 80 | <n | Start of Node object |
06 00 00 00 | id="6" | |
00 02 08 00 BA 03 AC 00 4F 7A B1 00 |
p="177.48 172.01" | |
00 00 | > | End of Node object |
05 80 | <b | Start of Bond object |
02 00 00 00 | id="2" | omitted from CDXML because it is optional |
04 06 04 00 05 00 00 00 | B="5" | |
05 06 04 00 06 00 00 00 | E="6" | |
00 00 | > | End of Bond object |
04 80 | <n | Start of Node object |
04 00 00 00 | id="4" | |
00 02 08 00 BA 03 AC 00 B0 85 77 00 |
p="119.52 172.01" | |
00 00 | > | End of Node object |
05 80 | <b | Start of Bond object |
03 00 00 00 | id="3" | omitted from CDXML because it is optional |
04 06 04 00 05 00 00 00 | B="5" | |
05 06 04 00 04 00 00 00 | E="4" | |
00 00 | > | End of Bond object |
00 00 | > | End of Fragment object |
00 00 | > | End of Page object |
00 00 | > | End of Document |
Return to Introduction
Continue to less-simple example