Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Saving and Retrieving Data in XMLSaving and retrieving data in XML. require 'chilkat' # Create an XML file with data that will later be loaded and # accessed by field name: xml = Chilkat::CkXml.new() xml.put_Tag("emailData") xml.NewChild2("from","admin@chilkatsoft.com") xml.NewChild2("toName","Chilkat Support") xml.NewChild2("toAddr","support@chilkatsoft.com") xml.NewChild2("subject","This is a test") xml.NewChild2("body","This is an email body") # Save the XML: success = xml.SaveXml("emailData.xml") if (success != true) print xml.lastErrorText() + "\n" exit end xml2 = Chilkat::CkXml.new() # Load the XML file: success = xml2.LoadXmlFile("emailData.xml") if (success != true) print xml2.lastErrorText() + "\n" exit end # Access the data by name print xml2.getChildContent("from") + "\n"; print xml2.getChildContent("toName") + "\n"; print xml2.getChildContent("toAddr") + "\n"; print xml2.getChildContent("subject") + "\n"; print xml2.getChildContent("body") + "\n"; print "------" + "\n"; # Let's say I want to load this into an email object: email = Chilkat::CkEmail.new() email.put_From(xml2.getChildContent("from")) toName = xml2.getChildContent("toName") toAddr = xml2.getChildContent("toAddr") email.AddTo(toName,toAddr) email.put_Subject(xml2.getChildContent("subject")) email.put_Body(xml2.getChildContent("body")) print email.getMime() + "\n"; |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.