#js2yml
JS- yml- (-)
npm install js2yml
var js2yml = require('js2yml'),
xmlString
;
xmlString = js2yml.createYmlSync({
name: "TeaPots",
company: "Teapots",
url: "http://teapots.su",
currencies: [{id: 'RUB', rate: '1'}],
categories: [
{id: '1', name: ''},
{id: '2', name: ''}
],
offers: [
{
id: "123",
available: true,
bid: 21,
url: "http://teapots.su/catalog/51f129b3d9eb0c0800000016",
price: 5700,
currencyId: "RUB",
categoryId: "1",
picture: "https://lh6.googleusercontent.com/-j8pBC9x_IOY.jpg",
name: " ",
param: [{name: "", unit: ".", value: 110}]
}
]
});
console.log(xmlString);
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE yml_catalog "shops.dtd">
<yml_catalog date="2013-07-28 10:24">
<shop>
<name>TeaPots</name>
<company>Teapots</company>
<url>http://teapots.su</url>
<currencies>
<currency id="RUB" rate="1"/>
</currencies>
<categories>
<category id="1"></category>
<category id="2"></category>
</categories>
<offers>
<offer id="123" available="true" bid="21">
<url>http://teapots.su/catalog/51f129b3d9eb0c0800000016</url>
<price>5700</price>
<currencyId>RUB</currencyId>
<categoryId>1</categoryId>
<picture>https://lh6.googleusercontent.com/-j8pBC9x_IOY.jpg</picture>
<name> </name>
<param name="" unit=".">110</param>
</offer>
</offers>
</shop>
</yml_catalog>