The debate of YAML vs XML and XML vs JSON is not new...<br>Can YAML really replace&nbsp; XML?<br>To be frank, whatever can&nbsp; be done in XML can be done without XML. <br>Do you need XML for XML-RPC? Yes, <br>Is it necessary to use XML for RPC? No.<br>
Is it necessary to use XML for RDF? No. <br>Is it necessary to use XML for, anything? No. <br>Is YAML a perfect replacement for XML? No<br>Are there&nbsp; circumstances, YAML may be more suitable than XML.<br><a href="http://www.ibm.com/developerworks/xml/library/x-matters23.html">http://www.ibm.com/developerworks/xml/library/x-matters23.html</a><br>
<br>YAML is designed with scripting languages (such as Python, Perl, PHP, and Ruby, among others) in mind.<br>Using Python to parse YAML<br>PyYAML is designed to be a Python parser.<br><br>&lt;user id=&quot;MyPBX&quot; on=&quot;localbox&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;firstname&gt;John&lt;/firstname&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;lastname&gt;QPublic&lt;/lastname&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;department&gt;QA&lt;/department&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;cell&gt;678-255-1185&lt;/cell&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;address password=&quot;xxxx&quot;&gt;<a href="mailto:jqpublic@myaml.com">jqpublic@myaml.com</a>&lt;/address&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;address password=&quot;xxxx&quot;&gt;<a href="mailto:jqpublic@myxml.com">jqpublic@myxml.com</a>&lt;/address&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/user&gt;<br><br>Now, contrast this with what I would enter for the YAML file:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MyPBX:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; computer : localbox<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; firstname: John<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lastname: QPublic<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cell: 678-255-1185<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addresses:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - address: <a href="mailto:jqpublic@example1.com">jqpublic@example1.com</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password: xxxxxxxx<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - address: <a href="mailto:jqpublic@example2.com">jqpublic@example2.com</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; password: xxxxxxxx<br><br><br>Assuming we created a yaml document, and read the above&nbsp; YAML structure into Python,&nbsp; the resulting structure may look like:<br>
<br>{mypbx: {computer: localbox, firstname: John, lastname: QPublic, cell: 678, 255,1212, addresses: [{address: <a href="mailto:jqpublic@myaml.com">jqpublic@myaml.com</a>, password: xxxxxxxx},{address: <a href="mailto:jqpublic@myxml.com">jqpublic@myxml.com</a>, password: xxxxxxxx}]} <br>
<br><a href="http://www.yaml.org/refcard.html">http://www.yaml.org/refcard.html</a><br><a href="http://yaml4r.sourceforge.net/cookbook/">http://yaml4r.sourceforge.net/cookbook/</a><br><a href="http://pyyaml.org/">http://pyyaml.org/</a><br>
<br>So what about JSON then. is not JSON better than XML, YAML or OGDL?<br><a href="http://scripting.wordpress.com/2006/12/20/scripting-news-for-12202006/">http://scripting.wordpress.com/2006/12/20/scripting-news-for-12202006/</a><br>
Briefly these do similar things in a different way. <br>JSON works well with Javascript. <br>YAML works without modification in Python and Ruby. <br>XML works with almost every language having xml libraries.<br>OGDL is similar to YAML and seems to now be adopted by JAVA<br>
<a href="http://ogdl.sourceforge.net/">http://ogdl.sourceforge.net/</a><br>