Comparing delta values of one xml file in other xml file

Hi All,

I have two xml files.

One is having below input

 
<NameValuePair>
            <name>Daemon</name>
            <value>tcp:7474</value>
        </NameValuePair>
        <NameValuePair>
            <name>Network</name>
            <value></value>
        </NameValuePair>
        <NameValuePair>
            <name>Service</name>
            <value>7474</value>
        </NameValuePair>
        <NameValuePair>
            <name>TestString</name>
            <value>Test</value>
        </NameValuePair>

Second is having :-

 
<KeyValuePairs>
<Key>TestString</Key>
<Value>Test12_Pollings</Value>
</KeyValuePairs>

I have to read the second file, In that need to read Key Value "TestString" and check if it just contain in the second file and generate the success as output.

Well behaved xml can be mined with text tools like sed and awk. For instance:

sed -n '
    s/.*<Key>\([^<]*\)<.*/\1/p
  ' file2

says do not print unless commanded, substitute for a line with the Key Element opener, content and any element closer just the content and print it. Note that the regex has .* on both ends to sweep away all else on the line.

Like this ?

$ cat <<test | awk '/^<Key>/{gsub(/<Key>|<\/Key>/,x);print $0 == Value ? "Success" : "Failure" ;exit}' Value="TestString"
<KeyValuePairs>
<Key>TestString</Key>
<Value>Test12_Pollings</Value>
</KeyValuePairs>
test

Success

for file try this

$ awk '/^<Key>/{gsub(/<Key>|<\/Key>/,x);print $0 == Value ? "Success" : "Failure" ;exit}' Value="TestString" file