Jump to content

Need help in xml file


Deoctor

Recommended Posts

Hai

i have a one xml file which have the format like this

<page src="20091215a_009101" sec="_" ftype= ".jpg" height="504" width="326">

<text>CRICKET  Fingleton IT Jack LOVELY WAS</text>

<zones>

<zone coor="19,113:300,130" type="TOC" TOCcont= "IT WAS LOVELY CRICKET" TOClink= "1" />

<zone coor="17,131:299,146" type="TOC" TOCcont= "CIRCUS CRICKET, A BORE" TOClink= "57" />

<zone coor="17,148:301,162" type="TOC" TOCcont= "SEASONS SUMMARY" TOClink= "63" />

<zone coor="15,163:306,191" type="TOC" TOCcont= "CRICKETERS OF THE YEAR" TOClink= "70" />

<zone coor="17,192:304,209" type="TOC" TOCcont= "VICTIM OF INDIFFERENCE" TOClink= "98" />

<zone coor="19,212:301,240" type="TOC" TOCcont= "RANJI TROPHY CHAMPIONSHIP" TOClink= "109" />

<zone coor="12,241:301,254" type="TOC" TOCcont= "FOR A CHANGE, GUJARAT" TOClink= "117" />

<zone coor="18,258:301,271" type="TOC" TOCcont= "LESS GLAMOUR, LOVELY PERFORMANCES" TOClink= "119" />

<zone coor="20,274:298,287" type="TOC" TOCcont= "U. P.-ALL THE WAY" TOClink= "123" />

<zone coor="14,290:310,305" type="TOC" TOCcont= "ON A SET PATTERN" TOClink= "125" />

<zone coor="18,306:300,321" type="TOC" TOCcont= "DELHI DOMINATES" TOClink= "129" />

<zone coor="22,321:298,338" type="TOC" TOCcont= "DULEEP TROPHY-GLORIFIED TRIALS" TOClink= "380" />

<zone coor="18,338:300,350" type="TOC" TOCcont= "BOMBAYS CUP OF WOE" TOClink= "389" />

<zone coor="22,352:306,370" type="TOC" TOCcont= "POOR CROWDS-WHY?" TOClink= "392" />

<zone coor="24,372:309,386" type="TOC" TOCcont= "ENGLAND SCHOOLBOYS IN INDIA" TOClink= "396" />

<zone coor="23,387:304,400" type="TOC" TOCcont= "SOUTH TRIUMPHS" TOClink= "402" />

<zone coor="22,403:309,415" type="TOC" TOCcont= "MAIDEN TRIUMPH FOR NORTH" TOClink= "405" />

<zone coor="19,416:303,431" type="TOC" TOCcont= "ENGLAND BANK ON YOUTH" TOClink= "422" />

<zone coor="19,433:302,447" type="TOC" TOCcont= "CRICKET IN SRI LANKA" TOClink= "433" />

<zone coor="16,449:302,469" type="TOC" TOCcont= "SRI LANKA CRICKETER OF THE YEAR" TOClink= "439" />

</zones>

</page>

 

so now wht should i do is like i need to find the TOClink and add 70 to the number which is already there..

can we do it using php???

Help would b appreciated

Link to comment
Share on other sites

you could parse the xml and then rewrite it or you could simply do this

 

      <?php

    $str = '<page src="20091215a_009101" sec="_" ftype= ".jpg" height="504" width="326">
    <text>CRICKET  Fingleton IT Jack LOVELY WAS</text>
    <zones>
    <zone coor="19,113:300,130" type="TOC" TOCcont= "IT WAS LOVELY CRICKET" TOClink= "1" />
    <zone coor="17,131:299,146" type="TOC" TOCcont= "CIRCUS CRICKET, A BORE" TOClink= "57" />
    <zone coor="17,148:301,162" type="TOC" TOCcont= "SEASONS SUMMARY" TOClink= "63" />
    <zone coor="15,163:306,191" type="TOC" TOCcont= "CRICKETERS OF THE YEAR" TOClink= "70" />
    <zone coor="17,192:304,209" type="TOC" TOCcont= "VICTIM OF INDIFFERENCE" TOClink= "98" />
    <zone coor="19,212:301,240" type="TOC" TOCcont= "RANJI TROPHY CHAMPIONSHIP" TOClink= "109" />
    <zone coor="12,241:301,254" type="TOC" TOCcont= "FOR A CHANGE, GUJARAT" TOClink= "117" />
    <zone coor="18,258:301,271" type="TOC" TOCcont= "LESS GLAMOUR, LOVELY PERFORMANCES" TOClink= "119" />
    <zone coor="20,274:298,287" type="TOC" TOCcont= "U. P.-ALL THE WAY" TOClink= "123" />
    <zone coor="14,290:310,305" type="TOC" TOCcont= "ON A SET PATTERN" TOClink= "125" />
    <zone coor="18,306:300,321" type="TOC" TOCcont= "DELHI DOMINATES" TOClink= "129" />
    <zone coor="22,321:298,338" type="TOC" TOCcont= "DULEEP TROPHY-GLORIFIED TRIALS" TOClink= "380" />
    <zone coor="18,338:300,350" type="TOC" TOCcont= "BOMBAYS CUP OF WOE" TOClink= "389" />
    <zone coor="22,352:306,370" type="TOC" TOCcont= "POOR CROWDS-WHY?" TOClink= "392" />
    <zone coor="24,372:309,386" type="TOC" TOCcont= "ENGLAND SCHOOLBOYS IN INDIA" TOClink= "396" />
    <zone coor="23,387:304,400" type="TOC" TOCcont= "SOUTH TRIUMPHS" TOClink= "402" />
    <zone coor="22,403:309,415" type="TOC" TOCcont= "MAIDEN TRIUMPH FOR NORTH" TOClink= "405" />
    <zone coor="19,416:303,431" type="TOC" TOCcont= "ENGLAND BANK ON YOUTH" TOClink= "422" />
    <zone coor="19,433:302,447" type="TOC" TOCcont= "CRICKET IN SRI LANKA" TOClink= "433" />
    <zone coor="16,449:302,469" type="TOC" TOCcont= "SRI LANKA CRICKETER OF THE YEAR" TOClink= "439" />
    </zones>
    </page>';

     echo preg_replace('#TOClink= "(\d+)"#e', "'TOClink= \"'.($1+70).'\"'", $str);


      
      ?>

Link to comment
Share on other sites

dude really awesome..

but i need one more help

it has to read the complete xml file and need to change these values where ever there is this TOClink value is there..

can you help..

i cannot give the entire xml as a string...

 

it has to read from the xml and then scan for the TOClink and then add 70 to it

Please help

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.