Converting String to XML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dillipkumar
    New Member
    • Mar 2008
    • 41

    Converting String to XML

    Hi,

    I am having a string.

    I want to convert the string into a xml file.


    $string="[Profile=[CustNumber=60, CustName=Dk, CustAttrs={TITL E=ABC}, SegmentCode=[Value=Account, Domain=CUS], Credit=[Value=C, Domain=CUS], AccCategory=[Value=FAMILY, Domain=CUS], ScProfile=[Value=SER_C_PRO F, Domain=CUS], ComProfile=[Value=COM_PROF, Domain=CUS], Channel=[Value=DISTRIBUT E, Domain=CUS], Market=[Value=MARKET, Domain=CUS], Vip=[Value=VIP_02, Domain=CUS], Dealer=[Value=Central, Domain=CUS], Operator=[Value=East, Domain=CUS], AddingProfile=[AddPeriod=[Value=BR05, Domain=ACC], InvoiceCurrency =[Value=KZT, Domain=ACC], AddDispatch=[Value=E-Mail, Domain=ACC], AddFormat=[Value=Itemized, Domain=ACC], ChargeThreshold =22.0, CreditThreshold =12.0, Domain=CUS], EditProfile=[av=null, bnkData=[altBankAccountN umber=7143, altBankBranchCo de=7777, altBankBranchNa me=CBA, bankAccountNumb er=null, bankAccountType =null, bankAgencyCode= null, bankAgencyName= null, bankBranchCode= null, bankBranchName= null, bankCode=null, bankIban=null, bankName=null, cardFromDate=nu ll, cardNumber=null , cardToDate=null], blTyCd=null, blAddr=null, custAnn=Annotat ion1, EditProfile=nul l, pymtTyCd=credit card], OwnerProfile=[birthDate=1978-12-12, companyDepartme nt=IT, companyName=ABC Co, companyTitle=Pr oductBased, firstName=dk, gender=M, lastName=joshep h, mdleName=K, prefix=Mr, suffix=suffix_1 , title=SE], OwningCost=[Value=CST_CENT_ 1, Domain=ACC], ReceivingCost=[Value=CST_CENT_ 2, Domain=ACC]], Addresses=[[AddrType=99, AddrName=LINK_R OAD, Ext=5555, PostCode=777777 , Country=ind, AddrItems={FIEL D_STR=Customer4 2}]]]";


    Can anybody plz tell me how to do this.


    ~Thanks
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    It looks like everything in there is comma separated. You should be able to split on that initially. Each key and value can then be separated on the equals sign. From there you should be able to output the XML you like.

    Comment

    Working...