krish_s Posted August 24, 2009 Share Posted August 24, 2009 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Story Self="123" AppliedTOCStyle="n" TrackChanges="false" StoryTitle="$ID/" AppliedNamedGrid="n"> <StoryPreference OpticalMarginAlignment="false" OpticalMarginSize="12" FrameType="TextFrameType" StoryOrientation="Horizontal" StoryDirection="LeftToRightDirection"/> <InCopyExportOption IncludeGraphicProxies="true" IncludeAllResources="false"/> </Story> I have an existing xml file as shown above. I should add/append a xml string as a child to the Story tag(just before '</Story>' tag). The Sample string to be appended is, <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]" Hyphenation="false"> <Properties> <TabList type="list"> <ListItem type="record"> <Alignment type="enumeration">RightAlign</Alignment> <AlignmentCharacter type="string">.</AlignmentCharacter> <Leader type="string"></Leader> <Position type="unit">126</Position> </ListItem> </TabList> </Properties> </ParagraphStyleRange> So the final output should be look like this, <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Story Self="123" AppliedTOCStyle="n" TrackChanges="false" StoryTitle="$ID/" AppliedNamedGrid="n"> <StoryPreference OpticalMarginAlignment="false" OpticalMarginSize="12" FrameType="TextFrameType" StoryOrientation="Horizontal" StoryDirection="LeftToRightDirection"/> <InCopyExportOption IncludeGraphicProxies="true" IncludeAllResources="false"/> <ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]" Hyphenation="false"> <Properties> <TabList type="list"> <ListItem type="record"> <Alignment type="enumeration">RightAlign</Alignment> <AlignmentCharacter type="string">.</AlignmentCharacter> <Leader type="string"></Leader> <Position type="unit">126</Position> </ListItem> </TabList> </Properties> </ParagraphStyleRange> </Story> Any suggestion to achieve this using PHP and any XML technology(DOM XML/SimpleXML) would be appreciatable. Link to comment https://forums.phpfreaks.com/topic/171673-edit-and-update-an-existing-xml-file-using-php/ Share on other sites More sharing options...
ignace Posted August 24, 2009 Share Posted August 24, 2009 Take a look at dom Link to comment https://forums.phpfreaks.com/topic/171673-edit-and-update-an-existing-xml-file-using-php/#findComment-905233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.