- private function convertToXML():void
- {
- var product:ProductVO = new ProductVO();
- product.id = 12;
- product.name = ‘test product’;
- product.description = ‘test desc’;
- product.price = 100;
- product.thumbnail = ‘image1.jpg’;
- var xmlProduct:XML = voToXml(product, ‘product’);
- }
- private static function voToXml(vo:Object, qName:String):XML
- {
- var qn:QName = new QName(qName);
- var xmlDocument:XMLDocument = new XMLDocument();
- var simpleXMLEncoder:SimpleXMLEncoder = new SimpleXMLEncoder(xmlDocument);
- var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(vo, qn, xmlDocument);
- var xml:XML = new XML(xmlDocument.toString());
- return xml;
- }
VO to XML converter
最新推荐文章于 2020-04-28 16:43:20 发布