📚 SAP Business One SDK Help

GetDataInterfaceFromXMLString Method
See Also  Example
bstrXMLString

The XML with which to create the object.

Description

Creates an object from XML.

Syntax

Visual Basic
Public Function GetDataInterfaceFromXMLString( _
   ByVal bstrXMLString As String _
) As Object

Parameters

bstrXMLString

The XML with which to create the object.

Remarks

The XML can be created using an object's ToXMLString method. 

The XML defines the object and its data. 

Example

Shows how to get a Report Layout from an XML string.
GetDataInterfaceFromXMLString (Visual Basic)Copy Code
Dim oCmpSrv As SAPbobsCOM.CompanyService
Dim oReportLayoutService As ReportLayoutsService
Dim oReportParam As ReportParams
Dim oDefaultReportParams As DefaultReportParams
Dim oDefaultReportParamsFrmStr As DefaultReportParams
Dim sReportParaDefault As String

'get company service
oCmpSrv = oCompany.GetCompanyService

'get report layout service
oReportLayoutService = oCmpSrv.GetBusinessService(ServiceTypes.ReportLayoutsService)

'get report params
oReportParam = oReportLayoutService.GetDataInterface(ReportLayoutsServiceDataInterfaces.rlsdiReportParams)

'set the report code
'the report code is the document type code (e.g. POR2=PurchaseOrder)
oReportParam.ReportCode = "POR2"

'get the default layout of the specific document (for Purchase Order)
oDefaultReportParams = oReportLayoutService.GetDefaultReport(oReportParam)

'save to xml string
sReportParaDefault = oDefaultReportParams.ToXMLString()

'create DefaultReportParams from xml file
oDefaultReportParamsFrmStr = oReportLayoutService.GetDataInterfaceFromXMLString(sReportParaDefault)
Create object from XML string (C#)Copy Code
public void AddFromXMLString(Hashtable Properties) 

    //Store GeneralData object as XML 
    SAPbobsCOM.GeneralService oGeneralService; 
    SAPbobsCOM.GeneralData oGeneralData; 
    SAPbobsCOM.GeneralData oGeneralDataXML; 
    string XMLString; 
 
    oGeneralService = cConnection.Instance.DICompanyService.GetGeneralService(UDOID); 
    oGeneralData = (GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData); 
 
    foreach (DictionaryEntry Pair in Properties) 
        oGeneralData.SetProperty(Pair.Key.ToString(), Pair.Value.ToString()); 
 
    XMLString = oGeneralData.ToXMLString(); 
 
    //Retrieve XML string and create GeneralData object from the XML  
    oGeneralDataXML = (GeneralData)oGeneralService.GetDataInterfaceFromXMLString(XMLString); 
    oGeneralService.Add(oGeneralDataXML); 

See Also