I need to make a php script which re-format one xml file into another xml file
Whats the best way to go about this? simpleXML seems to be the solution but I am not able to extract the value from each tag and put it into the right formatted file.
$xml = simplexml_load_file("file.xml");
//print_r($xml);
$array = json_decode(json_encode((array)$xml), TRUE);
eg.
original xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<ADI>
<Metadata>
<AMS Provider="" Product="MOD" Asset_Name="SpecialAgentOso1-03AViewToABook/Diamond'sAreForKitesPackageAsset" Version_Major="1" Version_Minor="0" Description="Special Agent Oso" Creation_Date="2014-10-20" Provider_ID="" Asset_ID="10010000000019545827" Asset_Class="package"/>
<App_Data App="MOD" Name="Metadata_Spec_Version" Value="CableLabsVOD1.1"/>
</Metadata>
<Asset>
<Metadata>
<AMS Provider="" Product="MOD" Asset_Name="SpecialAgentOso1-03AViewToABook/Diamond'sAreForKitesTitleAsset" Version_Major="1" Version_Minor="0" Description="Special Agent Oso" Creation_Date="2014-10-20" Provider_ID="" Asset_ID="10010100000019545827" Asset_Class="title"/>
<App_Data App="MOD" Name="Type" Value="title"/>
<App_Data App="MOD" Name="Title_Sort_Name" Value="Special Agent Oso"/>
<App_Data App="MOD" Name="Title_Brief" Value="SpecialAgentOSO1-03"/>
<App_Data App="MOD" Name="Title" Value="Special Agent Oso 1-03 A View To A Book/ Diamond's Are For Kites"/>
<App_Data App="MOD" Name="Episode_Name" Value="A View To A Book/ Diamond's Are For Kites"/>
<App_Data App="MOD" Name="Episode_ID" Value="Episode#03"/>
<App_Data App="MOD" Name="Summary_Medium" Value="When Joe needs a book to identify the toy dinosaurs he's taking to school, Oso borrows a book from the library. /When Sarah wants to be a part of Kite Day but isn't sure how to fly a kite, Oso helps Sarah find a kite and get it in the air."/>
<App_Data App="MOD" Name="Summary_Long" Value="When Joe needs a book to identify the toy dinosaurs he's taking to school, Oso borrows a book from the library. /When Sarah wants to be a part of Kite Day but isn't sure how to fly a kite, Oso helps Sarah find a kite and get it in the air."/>
<App_Data App="MOD" Name="Summary_Short" Value="When Joe needs a book to identify the toy dinosaurs he's taking to school, Oso borrows a book from the library. /When Sarah wants to be a part of Kite Day but isn't sure how to fly a kite, Oso helps Sarah find a kite and get it in the air."/>
<App_Data App="MOD" Name="Rating" Value="TV-Y"/>
<App_Data App="MOD" Name="Closed_Captioning" Value="Y"/>
<App_Data App="MOD" Name="Run_Time" Value="00:24:04"/>
<App_Data App="MOD" Name="Display_Run_Time" Value="00:24"/>
<App_Data App="MOD" Name="Year" Value="2008"/>
<App_Data App="MOD" Name="Country_of_Origin" Value="US"/>
<App_Data App="MOD" Name="Studio" Value="Disney"/>
<App_Data App="MOD" Name="Category" Value="Disney Junior On Demand/Special Agent OSO"/>
<App_Data App="MOD" Name="Genre" Value="Adventure"/>
<App_Data App="MOD" Name="Genre" Value="Mystery"/>
<App_Data App="MOD" Name="Genre" Value="Animation"/>
<App_Data App="MOD" Name="Box_Office" Value="0"/>
<App_Data App="MOD" Name="Billing_ID" Value="1003"/>
<App_Data App="MOD" Name="Licensing_Window_Start" Value="2014-11-07T00:00:00"/>
<App_Data App="MOD" Name="Licensing_Window_End" Value="2014-11-20T23:59:59"/>
<App_Data App="MOD" Name="Preview_Period" Value="0"/>
<App_Data App="MOD" Name="Provider_QA_Contact" Value="abc@abc.com"/>
<App_Data App="MOD" Name="Suggested_Price" Value="0.00"/>
</Metadata>
<Asset>
<Metadata>
<AMS Provider="" Product="MOD" Asset_Name="SpecialAgentOso1-03AViewToABook/Diamond'sAreForKitesMovieAsset" Version_Major="1" Version_Minor="0" Description="Special Agent Oso" Creation_Date="2014-10-20" Provider_ID="" Asset_ID="10010200000019545827" Asset_Class="movie"/>
<App_Data App="MOD" Name="Type" Value="movie"/>
<App_Data App="MOD" Name="Audio_Type" Value="Stereo"/>
<App_Data App="MOD" Name="HDContent" Value="N"/>
<App_Data App="MOD" Name="Viewing_Can_Be_Resumed" Value="N"/>
<App_Data App="MOD" Name="Watermarking" Value="N"/>
<App_Data App="MOD" Name="Copy_Protection" Value="N"/>
<App_Data App="MOD" Name="Content_FileSize" Value=""/>
<App_Data App="MOD" Name="Content_CheckSum" Value=""/>
</Metadata>
<Content Value="FOD31299.mpg"/>
</Asset>
</Asset>
</ADI>
after re-format xml
<?xml version="1.0">
<!DOCTYPE ADI SYSTEM "ADI.DTD">
<ADI>
<Metadata>
<AMS Provider="FAMILY" Product="MOD" Asset_Name="SpecialAgentOso1-03AViewToABook/Diamond'sAreForKitesPackageAsset" Version_Major="1" Version_Minor="0" Description="Special Agent Oso" Creation_Date="2014-10-20" Provider_ID="astral.com" Asset_ID="10010000000019545827" Asset_Class="PACKAGE"/>
<App_Data App="MOD" Name="Metadata_Spec_Version" Value="CableLabsVOD1.1"/>
</Metadata>
<Asset>
<Metadata>
<AMS Provider="FAMILY" Product="MOD" Asset_Name="SpecialAgentOso1-03AViewToABook/Diamond'sAreForKitesTitleAsset" Version_Major="1" Version_Minor="0" Description="Special Agent Oso" Creation_Date="2014-10-20" Provider_ID="astral.com" Asset_ID="10010100000019545827" Asset_Class="TITLE"/>
<App_Data App="MOD" Name="Type" Value="title"/>
<App_Data App="MOD" Name="Title_Brief" Value="SpecialAgentOSO1-03"/>
<App_Data App="MOD" Name="Title" Value="SpecialAgentOSO1-03"/>
<App_Data App="MOD" Name="Show_Type" Value="Series"/>
<App_Data App="MOD" Name="Episode_Name" Value="A View To A Book/ Diamond's Are For Kites"/>
<App_Data App="MOD" Name="Episode_ID" Value="03"/>
<App_Data App="MOD" Name="Series_Name" Value="Special Agent Oso"/>
<App_Data App="MOD" Name="Season_Number" Value="1"/>
<App_Data App="MOD" Name="Summary_Long" Value="When Joe needs a book to identify the toy dinosaurs he's taking to school, Oso borrows a book from the library. /When Sarah wants to be a part of Kite Day but isn't sure how to fly a kite, Oso helps Sarah find a kite and get it in the air."/>
<App_Data App="MOD" Name="Summary_Long" Value="When Joe needs a book to identify the toy dinosaurs he's taking to school, Oso borrows a book from the library. /When Sarah wants to be a part of Kite Day but isn't sure how to fly a kite, Oso helps Sarah find a kite and get it in the air."/>
<App_Data App="MOD" Name="Rating" Value="G"/>
<App_Data App="MOD" Name="Closed_Captioning" Value="Y"/>
<App_Data App="MOD" Name="Run_Time" Value="00:24:04"/>
<App_Data App="MOD" Name="Display_Run_Time" Value="00:24"/>
<App_Data App="MOD" Name="Year" Value="2008"/>
<App_Data App="MOD" Name="Actors" Value="N/A"/>
<App_Data App="MOD" Name="Director" Value="N/A"/>
<App_Data App="MOD" Name="Canadian_Content" Value="0"/>
<App_Data App="MOD" Name="Country_Of_Origin" Value="USA"/>
<App_Data App="MOD" Name="Category" Value="Subscription/Family & Kids/Disney Junior On Demand/Special Agent OSO"/>
<App_Data App="MOD" Name="Genre" Value="Series/All"/>
<App_Data App="MOD" Name="Genre" Value="Children"/>
<App_Data App="MOD" Name="Billing_ID" Value="1003"/>
<App_Data App="MOD" Name="Licensing_Window_Start" Value="2014-11-07T00:00:00"/>
<App_Data App="MOD" Name="Licensing_Window_End" Value="2014-11-20T23:59:59"/>
<App_Data App="MOD" Name="Preview_Period" Value="0"/>
<App_Data App="MOD" Name="Maximum_Viewing_Length" Value="1440"/>
<App_Data App="MOD" Name="Provider_QA_Contact" Value="abc@abc.com"/>
<App_Data App="MOD" Name="Suggested_Price" Value="0.00"/>
</Metadata>
<Asset>
<Metadata>
<AMS Provider="FAMILY" Product="MOD" Asset_Name="SpecialAgentOSO1-03MetadataMovieAsset" Version_Major="1" Version_Minor="0" Description="SpecialAgentOSO1-03 Metadata Movie Asset" Creation_Date="2014-10-20" Provider_ID="astral.com" Asset_ID="10010200000019545827" Asset_Class="MOVIE"/>
<App_Data App="MOD" Name="Encryption" Value="Y"/>
<App_Data App="MOD" Name="Type" Value="movie"/>
<App_Data App="MOD" Name="Audio_Type" Value="stereo"/>
<App_Data App="MOD" Name="HDContent" Value="N"/>
<App_Data App="MOD" Name="Copy_Protection" Value="Y"/>
<App_Data App="MOD" Name="Languages" Value="en"/>
</Metadata>
<Content Value="FOD31299.mpg"/>
</Asset>
<Asset>
<Metadata>
<AMS Provider="FAMILY" Product="MOD" Asset_Name="SpecialAgentOSO1-03MetadataPreviewAsset" Version_Major="1" Version_Minor="0" Description="SpecialAgentOSO1-03 Metadata Preview Asset" Creation_Date="2014-10-20" Provider_ID="astral.com" Asset_ID="10010300000019545827" Asset_Class="PREVIEW"/>
<App_Data App="MOD" Name="Type" Value="preview"/>
</Metadata>
<Content Value="FOD31299_preview.mpg"/>
</Asset>
<Asset>
<Metadata>
<AMS Provider="FAMILY" Product="MOD" Asset_Name="SpecialAgentOSO1-03MetadataPosterAsset" Version_Major="1" Version_Minor="0" Description="SpecialAgentOSO1-03 Metadata Poster Asset" Creation_Date="2014-10-20" Provider_ID="astral.com" Asset_ID="10010400000019545827" Asset_Class="POSTER"/>
<App_Data App="MOD" Name="Type" Value="poster"/>
</Metadata>
<Content Value="FOD31299_poster.jpg"/>
</Asset>
</Asset>
</ADI>