txmldoc_savefile.bmx 895 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. SuperStrict
  2. Framework Text.xml
  3. Import BRL.StandardIO
  4. ' Create a new document
  5. Local doc:TxmlDoc = TxmlDoc.newDoc("1.0")
  6. If doc Then
  7. ' create a test stream
  8. Local stream:TTestStream = TTestStream.Create()
  9. ' create a new node, initially not attached to the document
  10. Local root:TxmlNode = TxmlNode.newNode("root")
  11. ' set the node as the document root node
  12. doc.setRootElement(root)
  13. root.addChild("things", "some stuff")
  14. ' output the document to a file
  15. doc.saveFile("testfile.xml")
  16. ' output the document to a stream
  17. doc.saveFile(stream)
  18. ' output the document to console
  19. doc.saveFile("-")
  20. doc.Free()
  21. End If
  22. Type TTestStream Extends TStream
  23. Function Create:TTestStream( )
  24. Return New TTestStream
  25. End Function
  26. Method Write:Long( buf:Byte Ptr, count:Long )
  27. Print "outputing..."
  28. Print String.FromBytes( buf, Int(count) )
  29. Return count
  30. End Method
  31. End Type