complex.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. var data2xml = require('../data2xml').data2xml;
  2. var data = {
  3. _attr : {
  4. xmlns : 'https://route53.amazonaws.com/doc/2011-05-05/',
  5. random : 'Quick test for \' and \"',
  6. },
  7. ChangeBatch : {
  8. Comment : 'This is a comment (with dodgy characters like < & > \' and ")',
  9. Changes : {
  10. Change : [
  11. {
  12. Action : 'CREATE',
  13. ResourceRecordSet : {
  14. Name : 'www.example.com',
  15. Type : 'A',
  16. TTL : 300,
  17. ResourceRecords : {
  18. ResourceRecord : [
  19. {
  20. Value : '192.0.2.1'
  21. }
  22. ]
  23. }
  24. },
  25. },
  26. {
  27. Action : 'DELETE',
  28. ResourceRecordSet : {
  29. Name : 'foo.example.com',
  30. Type : 'A',
  31. TTL : 600,
  32. ResourceRecords : {
  33. ResourceRecord : [
  34. {
  35. Value : '192.0.2.3'
  36. }
  37. ]
  38. }
  39. },
  40. },
  41. {
  42. Action : 'CREATE',
  43. ResourceRecordSet : {
  44. Name : 'foo.example.com',
  45. Type : 'A',
  46. TTL : 600,
  47. ResourceRecords : {
  48. ResourceRecord : [
  49. {
  50. Value : '192.0.2.1'
  51. }
  52. ]
  53. }
  54. },
  55. },
  56. ],
  57. },
  58. },
  59. };
  60. console.log(data2xml('ChangeResourceRecordSetsRequest', data));
  61. console.log();
  62. console.log(
  63. data2xml('TopLevelElement', {
  64. MyArray : [
  65. 'Simple Value',
  66. {
  67. _attr : { type : 'colour' },
  68. _value : 'White',
  69. }
  70. ],
  71. })
  72. );
  73. console.log();