Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Visual FoxPro) XML Add Child TreeDemonstrates the Xml.AddChildTree method.
LOCAL lnSuccess LOCAL loXml LOCAL loXml2 * Build the following XML: * <?xml version="1.0" encoding="utf-8"?> * <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> * <soap12:Body> * <cteDadosMsg xmlns="http://www.portalfiscal.inf.br/cte/wsdl/CTeStatusServicoV4"> * </cteDadosMsg> * </soap12:Body> * </soap12:Envelope> * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Xml') loXml = CreateObject('Chilkat.Xml') loXml.Tag = "soap12:Envelope" loXml.AddAttribute("xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance") loXml.AddAttribute("xmlns:xsd","http://www.w3.org/2001/XMLSchema") loXml.AddAttribute("xmlns:soap12","http://www.w3.org/2003/05/soap-envelope") loXml.UpdateAttrAt("soap12:Body|cteDadosMsg",1,"xmlns","http://www.portalfiscal.inf.br/cte/wsdl/CTeStatusServicoV4") * We want to add the following XML as a sub-tree under the "cteDadosMsg" element. * <consStatServCTe versao="4.00" xmlns="http://www.portalfiscal.inf.br/cte"> * <tpAmb>2</tpAmb> * <cUF>43</cUF> * <xServ>STATUS</xServ> * </consStatServCTe> * Build the XML to be added as a child tree. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Xml') loXml2 = CreateObject('Chilkat.Xml') loXml2.Tag = "consStatServCTe" loXml2.AddAttribute("versao","4.00") loXml2.AddAttribute("xmlns","http://www.portalfiscal.inf.br/cte") loXml2.UpdateChildContent("tpAmb","2") loXml2.UpdateChildContent("cUF","43") loXml2.UpdateChildContent("xServ","STATUS") * Add the child tree at the desired location: * Temporarily point to the location where we wish to add the child tree. lnSuccess = loXml.FindChild2("soap12:Body|cteDadosMsg") IF (lnSuccess = 0) THEN * Restore current location to the root. loXml.GetRoot2() RELEASE loXml RELEASE loXml2 CANCEL ENDIF lnSuccess = loXml.AddChildTree(loXml2) * Restore the current location to the root. loXml.GetRoot2() * You can see now that the XML contain the child tree: ? loXml.GetXml() * <?xml version="1.0" encoding="utf-8"?> * <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> * <soap12:Body> * <cteDadosMsg xmlns="http://www.portalfiscal.inf.br/cte/wsdl/CTeStatusServicoV4"> * <consStatServCTe versao="4.00" xmlns="http://www.portalfiscal.inf.br/cte"> * <tpAmb>2</tpAmb> * <cUF>43</cUF> * <xServ>STATUS</xServ> * </consStatServCTe> * </cteDadosMsg> * </soap12:Body> * </soap12:Envelope> RELEASE loXml RELEASE loXml2 |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.