test-tinyxml2.nut 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. local xml = TinyXml2.XMLDocument();
  2. local element = xml->InsertEndChild( xml->NewDeclaration() );
  3. local text = xml->InsertEndChild( xml.NewText("name") );
  4. text.Value("Domingo");
  5. print(text, text instanceof TinyXml2.XMLText);
  6. local comment = xml->InsertEndChild( xml.NewComment("Notes") );
  7. comment.Value("Hello World !");
  8. print(comment, type(comment));
  9. xml.SaveFile("test.xml");
  10. print(xml.tostring());
  11. xml.LoadFile("test.xml");
  12. print(xml.tostring());
  13. local doc = new TinyXml2.XMLDocument();
  14. element = doc->InsertEndChild( doc->NewDeclaration() );
  15. element = doc->InsertEndChild( doc->NewElement( "name" ) );
  16. element->InsertEndChild( doc->NewText( "Domingo" ) );
  17. element = doc->InsertEndChild( doc->NewElement( "parent" ) );
  18. text = element->InsertEndChild( doc->NewText( "Tais Brasil]" ) );
  19. text.CData(true);
  20. doc.SaveFile("doc.xml");
  21. print(doc.tostring());
  22. local printer = TinyXml2.XMLPrinter ();
  23. printer.PushHeader(true, true);
  24. printer.OpenElement( "foo" );
  25. printer.PushAttribute( "foo", "bar" );
  26. printer.CloseElement();
  27. print(printer.tostring());