Deoctor Posted December 16, 2009 Share Posted December 16, 2009 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 Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 16, 2009 Share Posted December 16, 2009 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); ?> Quote Link to comment Share on other sites More sharing options...
Deoctor Posted December 16, 2009 Author Share Posted December 16, 2009 the code is not working though.. the output is displaying is CRICKET Fingleton IT Jack LOVELY WAS any more ideas.. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 16, 2009 Share Posted December 16, 2009 yes it will view the source Quote Link to comment Share on other sites More sharing options...
Deoctor Posted December 16, 2009 Author Share Posted December 16, 2009 yes it will view the source i didnt got wht u are saying.. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 16, 2009 Share Posted December 16, 2009 view source of your browser since it xml it won't show on the browser since it does not have the xml tag. Quote Link to comment Share on other sites More sharing options...
Deoctor Posted December 16, 2009 Author Share Posted December 16, 2009 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 Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 16, 2009 Share Posted December 16, 2009 Yes it will. you can try the same thing out on the xml file your trying to process Quote Link to comment Share on other sites More sharing options...
Deoctor Posted December 16, 2009 Author Share Posted December 16, 2009 it resolved my query but cannot it be done by using the xml parser.. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 17, 2009 Share Posted December 17, 2009 Yes it can but you would have to parse the xml search its every node and do the calculation and then write it back I would guess that would be pretty lengthy code. Quote Link to comment Share on other sites More sharing options...
Deoctor Posted December 17, 2009 Author Share Posted December 17, 2009 i know how to get the values from the tags if they are <zone></zone> but i dont know how to get the attributes values in the xml. so please help me out... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.