Replace particular word in a XML document

Discussion in 'Programming' started by DragonSZ, Nov 29, 2011.

  1. #1
    Friends, in this code in each line "contact_name" is "Dave" ,it was a mistake. it should be like this.. In every YYYYYYY line [address="YYYYYYY"] , the contact_name="Dave" should be like contact_name="Carolin" and other particular lines are OK. Can anyone tell me how to re correct/Replace this?? Thank you.

    <sms protocol="0" address="XXXXXXX" date="1320100356651" type="2" toa="null" contact_name="Dave" />
    <sms protocol="0" address="YYYYYYY" date="1320100499747" type="1" toa="null" contact_name="Dave" />
    <sms protocol="0" address="XXXXXXX" date="1320100774796" type="2" toa="null" contact_name="Dave" />
    <sms protocol="0" address="YYYYYYY" date="1320100808585" type="1" toa="null" contact_name="Dave" />
    <sms protocol="0" address="XXXXXXX" date="1320100857870" type="2" toa="null" contact_name="Dave" />
    Code (markup):
     
    DragonSZ, Nov 29, 2011 IP
  2. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #2
    Very simple. Cut and paste the XML document into a text viewer. Search and replace each incorrect "Dave" with "Carolin". Copy the corrected text back to the XML file.
     
    mmerlinn, Nov 29, 2011 IP
  3. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #3
    I almost answered this with that same answer as a joke. I'm sure you were perfectly serious @mmerlinn.
     
    drhowarddrfine, Nov 29, 2011 IP
  4. mmerlinn

    mmerlinn Prominent Member

    Messages:
    3,197
    Likes Received:
    819
    Best Answers:
    7
    Trophy Points:
    320
    #4
    Based on what he asked, my answer is the best answer, so, you are correct, I was perfectly serious.:)

    However, I suspect that he did not ask the correct question, in which case my answer is completely useless.:D
     
    mmerlinn, Nov 29, 2011 IP
  5. DragonSZ

    DragonSZ Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I think you haven't got what i meant. I don't need to replace every "Dave" only for lines which have [address="YYYYYYY"] phrase.
     
    DragonSZ, Nov 30, 2011 IP
  6. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #6
    Find: type="1" toa="null" contact_name="Dave"
    Replace: type="1" toa="null" contact_name="Carolin"
     
    MyVodaFone, Nov 30, 2011 IP
  7. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #7
    This is one of the most bizarre threads I have ever seen but not unexpected on DP.
     
    drhowarddrfine, Dec 1, 2011 IP