Search

Hello, I need to convert an xml document back to same type but with the exception that all the addresses with the same id having different address lines be converted into a comma separated list. So the following xml

10ArubaCA 94555-3658Ntest text xyz10ArubaCA 94555-3658Ntest temp10ArubaCA 94555-3658Ntest3 gtrgtrrthyty11UKCA 9fd5-3658Ntest

be converted into

10ArubaCA 94555-3658Ntest text xyz,test temp,test3 gtrgtrrthyty11UKCA 9fd5-3658Ntest

Thanks in advance

Looks like the copy paste didn’t work properly

Intial xml is

<SearchResultsAddressDataSet xmlns="http://tempuri.org/SearchResultsAddressDataSet.xsd"> <AddressResults><ID>10</ID><Country>Aruba</Country><PostalCode>CA 94555-3658</PostalCode><Deleted>N</Deleted><lAddressLines>test text xyz</lAddressLines></AddressResults> <AddressResults><ID>10</ID><Country>Aruba</Country><PostalCode>CA 94555-3658</PostalCode><Deleted>N</Deleted><lAddressLines>test temp</lAddressLines></AddressResults> <AddressResults><ID>10</ID><Country>Aruba</Country><PostalCode>CA 94555-3658</PostalCode><Deleted>N</Deleted><lAddressLines>test3 gtrgtrrthyty</lAddressLines></AddressResults> <AddressResults><ID>11</ID><Country>UK</Country><PostalCode>CA 9fd5-3658</PostalCode><Deleted>N</Deleted><lAddressLines>test</lAddressLines></AddressResults></SearchResultsAddressDataSet>

the resultant xml :

<SearchResultsAddressDataSet xmlns="http://tempuri.org/SearchResultsAddressDataSet.xsd"> <AddressResults><ID>10</ID><Country>Aruba</Country><PostalCode>CA 94555-3658</PostalCode><Deleted>N</Deleted><lAddressLines>test text xyz,test temp,test3 gtrgtrrthyty</lAddressLines></AddressResults> <AddressResults><ID>11</ID><Country>UK</Country><PostalCode>CA 9fd5-3658</PostalCode><Deleted>N</Deleted><lAddressLines>test</lAddressLines></AddressResults></SearchResultsAddressDataSet>

Somehow the xml I am pasting is not appearing correctly

@Urvashi - Try using pastie.org and paste the url of the code here in the forum.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details