Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Posts
    17

    Unanswered: Convert text file to XML using Born shell scripts

    If someone out there could help me out with this problem.
    Last edited by ram2s2001; 12-14-05 at 09:53.

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Maybe someone has a better idea, but this should get you started
    Code:
    #!/usr/bin/sh
    infile=$1
    outfile=$2
    >$outfile # truncate out file
    cat $infile | while read line
    do
      rectype=`echo $line | cut -c 1-2`
      if [ "$rectype" = "01" ]
      then 
        contrycode=`echo $line | cut -c 3-4`
        # and other fields
        cat <<EOF >>$outfile
    <header>
    <headid>$rectype</headid>
    <contry>$contrycode</country>
        # and other fields
    </header>
    EOF
      fi
      #if [ "$rectype" = "10" ]
      #...
    done
    Last edited by pdreyer; 10-21-05 at 09:51.

  3. #3
    Join Date
    Oct 2005
    Posts
    17

    xml to text file

    Thanks lot for your code ,do you have any idea to convert same xml file to text file(fixed lengths).
    Last edited by ram2s2001; 10-22-05 at 04:35.

  4. #4
    Join Date
    Oct 2005
    Posts
    17

    Text file to xml

    When iam trying to execute this script :sysntax error :"Unexpected end of
    Last edited by ram2s2001; 12-14-05 at 09:54.

  5. #5
    Join Date
    Oct 2005
    Posts
    17

    tyrtyr

    testhdfghfhfghfg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •