Recent posts:
Recent replies:

Hi,

Class MyApp.Person Extends (%Persistent, %XML.Adaptor, %RegisteredObject, MyApp.Address)
{

Parameter XMLNAME = "Person";

Property Name As %String;

Property DOB As %String;

Property Address As MyApp.Address;

Method Import() As %String
{
    
    Set reader = ##class(%XML.Reader).%New() 
    Set status = reader.OpenFile("C:\InterSystems\Ex.xml")
    If $$$ISERR(status) {do $System.Status.DisplayError(status)}
    Do reader.Correlate("Person","MyApp.Person")
    if $$$ISERR(status) {do $System.Status.DisplayError(status) quit $$$ERROR()}
    While (reader.Next(.object,.status)) {
       
       set ..Name = object.Name
       set ..DOB = object.DOB
       set ..Address.City = object.Address.City
       set ..Address.Zip = object.Address.Zip
       set ..City = object.Address.City
       set ..Zip = object.Address.Zip
       
        Write object.Name,!
        Write object.DOB,!
        write object.Address.City, !
        write object.Address.Zip
    }
      
    If $$$ISERR(status) {do $System.Status.DisplayError(status)}
    
    Quit $$$OK
}

Method GetTarget(ByRef pParameters As %String, Output pObject As %RegisteredObject) As %Status
{
  Set pObject = ##class(MyApp.Person).%New()
  set ins = pObject.Import()
  set status = pObject.%Save()
   set writer=##class(%XML.Writer).%New()
    set writer.Indent=1
    set statuswriter=writer.OutputToFile("C:\InterSystems\Outfile5.txt")
    set st = writer.StartWrite()
  set status2 =##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONFromObject(writer,pObject,,,,"cbwi")
 
  Quit $$$OK
}

}

//

Class MyApp.Address Extends (%SerialObject, %Populate, %Persistent, %XML.Adaptor)
{

Property City As %String;

Property Zip As %String;
}

Followers:
Following:
Vyshnavi has not followed anybody yet.
Global Masters badges:
Vyshnavi has no Global Masters badges yet.