Script is showing abnormal behavior...

Hi,

facing unusual problem, below are 2 same scripts, one is working and other is not. please help

--- THIS SCRIPT IS WORKING FINE!!!!
#! /bin/sh
phone=`grep "<phone>" data.xml | sed 's:<phone>::;s:</phone>::'`
echo "Phone Number is:"$phone
repnum=554156
cat data.xml | sed -e s/$phone/$repnum/ > newdata.xml

Input File:
data.xml:
<Name>ABCDEF</Name>
<phone>748347</phone>

Output file:
newdata.xml:
<Name>ABCDEF</Name>
<phone>554156</phone>

------THIS IS NOT ABLE TO REPLACE THE VALUE OF THE TAG "PolNumber"
#! /bin/sh
polnum=`grep "<PolNumber>" adi.xml | sed 's:<PolNumber>::;s:</PolNumber>::'`
echo "PolNumber is:"$polnum
newpol=101101
cat adi.xml | sed -e s/$polnum/$newpol/ > tmpadi.xml

Input file:

>cat adi.xml

                          &lt;Policy id="Policy_1"&gt;
                                    &lt;PolNumber&gt;109301793&lt;/PolNumber&gt;
                            &lt;/Policy&gt;

OutPut: is Same. File is not being updated with the new value..

Any clues?

Thanks in advance.

# cat data.xml
<?xml version="1.0"?>
<xml>
        <Name>ABCDEF</Name>
        <phone>748347</phone>
</xml>

# xml ed -P -u "//phone" -v "554156" data.xml > newdata.xml

# cat newdata.xml
<?xml version="1.0"?>
<xml>
        <Name>ABCDEF</Name>
        <phone>554156</phone>
</xml>

See: XmlStarlet Command Line XML Toolkit User's Guide

Working fine here

$more tmpadi.xml
<Policy id="Policy_1">
<PolNumber>101101</PolNumber>
</Policy>

The scripts are equivalent and should give the same output. I ran the second one and the output is

cat tmpadi.xml
<Policy id="Policy_1">
<PolNumber>101101</PolNumber>
</Policy>