Tham khảo tài liệu 'xml by example- p7', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Creating Documents Without DOM 285 var name dollars euros productList creates the various objects required var dollarsPrice new Price dollars usd eurosPrice new Price euros eur prices new Array dollarsPrice eurosPrice product new Product name prices arrays are zero-based so points to one past the latest product JavaScript automatically allocates memory var pos products pos product var option new Option name pos option function deleteProduct form var productList pos if pos -1 var product pos .value pos null products product null function exportProduct form continues 286 Chapter 9 Writing XML Listing continued makeXML function send var http new ActiveXObject POST http Dump false Content-type application xml value makeXML function makeXML var xmlCode var i for i 0 i i if products i null xmlCode products i .toXML return element products xmlCode function resetAll form document priceList null function element name attributes content var result name if attributes result attributes result Creating Documents Without DOM 287 result content result name r return result Ì function escapeXML string Í var result i c for i 0 i i Í c i if c result lt else if c result amp else result c Ì return result Ì declares two JavaScript objects product object function Product name prices Í name prices product_toXML Ì function product_toXML Í var result element name escapeXML .