YUI 3.x Home -

YUI Library Examples: DataType Utility: DataType.XML.format()

DataType Utility: DataType.XML.format()

The XML module of the DataType Utility allows you to take an XML document and convert it to a string.

To output an XML document as a string, simply call the format() function of the DataType.XML class:

  1. YUI().use("datatype-xml", function(Y) {
  2. var myXMLDoc = Y.DataType.XML.parse("<myroot><item type='foo'><name>Abc</name><rank>1</rank></item><item type='bar'><name>Def</name><rank>2</rank></item><item type='bat'><name>Ghhi</name><rank>3</rank></item></myroot>");
  3. alert(Y.DataType.XML.format(myXMLDoc));
  4. });
YUI().use("datatype-xml", function(Y) {
    var myXMLDoc = Y.DataType.XML.parse("<myroot><item type='foo'><name>Abc</name><rank>1</rank></item><item type='bar'><name>Def</name><rank>2</rank></item><item type='bat'><name>Ghhi</name><rank>3</rank></item></myroot>");
    alert(Y.DataType.XML.format(myXMLDoc));
});

Copyright © 2009 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings