Jump to content

Edit and Update an Existing XML file using PHP


krish_s

Recommended Posts

<?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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.