#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2011
    Posts
    1
    Rep Power
    0

    Help reqd in shell scripting..


    Hi guys,
    I am new to shell scripting and I need urgent assistance.
    I have an xml like :
    <AgreementNumberFull>13-WY-84252</AgreementNumberFull>
    <AgreementNumberAbbr>WY84252</AgreementNumberAbbr>
    <LineOfBusiness>F</LineOfBusiness>
    <CompanyCode>0005</CompanyCode>
    <UniqDigit/>
    <StateCode/>

    I need to write a script which parses this xml and returns the value of tags in string data type. If the value of the tag is null(eg:UniqDigit) then response string should be '0'
    The output for the above xml should be:
    13-WY-84252
    WY84252
    F
    0005
    0
    0.

    Please help me with this.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,400
    Rep Power
    1688
    I'd suggest looking at perl and using a dedicated XML parsing module to do this, or giving awk a go
    If you have to do it in shell script it will go a lot easier if you can guarantee that each tag will be on a single line.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo