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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.