Parsing the http post request

Hi,

I am trying to write a shell script to parse the post request data that it received to a xml file. Below is the post request data that script is receiving.

-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="param1"

1
-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="param2"

2
-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="param3"

3
-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="param4"

4
-----------------------------7dd2339190c8e
Content-Disposition: form-data; name="xmldata"

<ShapeInfo>
<Rectangles>
<Rectangle>
<top>47</top>
<left>169</left>
<bottom>173</bottom>
<right>343</right>
</Rectangle>
</Rectangles>
<Lines>
<Line>
<startX>349</startX>
<startY>127</startY>
<endX>499</endX>
<endY>274</endY>
</Line>
</Lines>
</ShapeInfo>

-----------------------------7dd2339190c8e--
!/bin/sh

echo "" > "file.xml"

if [ "$REQUEST_METHOD" = "POST" ]; then
    if [ "$CONTENT_LENGTH" -gt 0 ]; then
        while read -n $CONTENT_LENGTH POST_DATA <&0
        do
            echo "$POST_DATA" >> "file.xml"
         done
    fi
fi

How can I parse it and dump it into xml? Any reference?

Thanks,
Jdp

your request is not clear, any relationship between the code and xml sample file?

Thanks rdcwayx,

Actually I am making HTTP POST request from HTML/JavaScript file and is given to that .cgi file. I have input fields in HTML form which is posted back. Each field is a separate input field in HTML file.

I want to extract each field passed in POST request and dump then in one xml file. This xml file can be used in other application to read the updated values and take action accordingly.

Thanks,
Jdp