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

    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0

    Who can help me?


    Who can help?

    I need to extract the values from XML and put it in csv with cygwin but I don’t know how to do it.

    Here is the XML file:

    <MVV_LVC:Pand>
    <MVV_LVC:identificatie>0022100000010991</MVV_LVC:identificatie>
    <MVV_LVC:bouwjaar>1980</MVV_LVC:bouwjaar>
    <MVV_LVC:bron>
    <MVVtype:documentdatum>19800317</MVVtype:documentdatum>

    <MVV_LVC:Pand>
    <MVV_LVC:identificatie>0022100000010992</MVV_LVC:identificatie>
    <MVV_LVC:bouwjaar>1988</MVV_LVC:bouwjaar>
    <MVV_LVCandstatus> in gebruik</MVV_LVCandstatus>
    <MVV_LVC:bron>
    <MVVtype:documentdatum>19880802</MVVtype:documentdatum>

    I would like to make it look like this:
    0022100000010991, 1980, ,19800317
    0022100000010992, 1988, in gebruik, 19880802

    Please help.

    Thanks,
    Jenny
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    840
    Rep Power
    387

    Talking


    Try this:
    Code:
    tr '<>' '  ' <inFile.xml|\
    awk '
    /MVV_LVC:identificatie/{ln=$2}
    /MVV_LVC:bouwjaar/{ln=ln","$2}
    /MVVtype:documentdatum/{print ln","$2}
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0
    Originally Posted by LKBrwn_DBA
    Try this:
    Code:
    tr '<>' '  ' <inFile.xml|\
    awk '
    /MVV_LVC:identificatie/{ln=$2}
    /MVV_LVC:bouwjaar/{ln=ln","$2}
    /MVVtype:documentdatum/{print ln","$2}

    Thanks a lot for your help. You show me the right direction but there are still some difficulties.

    How can I add the “in gebruik” from MVV_LVCandstatus> in gebruik</MVV_LVCandstatus in the formula? This field is variable and that brings some difficulties with it.

    One more time thanks for your help.
    Jenny
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    840
    Rep Power
    387

    Cool


    Originally Posted by Jenny77
    Thanks a lot for your help. You show me the right direction but there are still some difficulties.

    How can I add the “in gebruik” from MVV_LVCandstatus> in gebruik</MVV_LVCandstatus in the formula? This field is variable and that brings some difficulties with it.

    One more time thanks for your help.
    Jenny
    Ooops, I missed that...
    Here:
    Code:
    tr '<>' '~~' <inFile.xml|\
    awk -F'~' '
    /MVV_LVC:identificatie/{id=$3;st=""}
    /MVV_LVC:bouwjaar/{bj=$3}
    /MVV_LVCandstatus/{st=$3}
    /MVVtype:documentdatum/{print id","bj","st","$3}
    '
    Last edited by LKBrwn_DBA; March 22nd, 2011 at 01:55 PM.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    3
    Rep Power
    0
    Originally Posted by LKBrwn_DBA
    Ooops, I missed that...
    Here:
    Code:
    tr '<>' '~~' <inFile.xml|\
    awk -F'~' '
    /MVV_LVC:identificatie/{id=$3;st=""}
    /MVV_LVC:bouwjaar/{bj=$3}
    /MVV_LVCandstatus/{st=$3}
    /MVVtype:documentdatum/{print id","bj","st","$3}
    '

    Thank you, thank you, thank you.
    I really appreciate your help.

    Greetings,

    Jenny

IMN logo majestic logo threadwatch logo seochat tools logo