how to retrieve specific parameters using a xml tag

Hi,

I have the following code in my xml file:

<aaaRule loginIdPattern=".*"
	orgIdPattern=".*" deny="false" />
<aaaRuleGroup name="dpaas">
	<aaaRule loginIdPattern=".*" orgIdPattern=".*"
		deny="false" />

I want to retrieve orgIdPattern and loginIdPattern parameter value based on "<aaaRule" tag. Please help me!!!!

You should really show what output you would like for the supplied file.

How about this:

awk '/<aaaRule /{for(i=2;i<NF;i++)
    if ($i ~ "^orgIdPattern=|l^oginIdPattern=") print $i}' RS='/>' infile

Output produced:

loginIdPattern=".*"
orgIdPattern=".*"
loginIdPattern=".*"
orgIdPattern=".*"
1 Like

something like this

tr -s " " "\n" < infile | egrep -o "loginIdPattern.*|orgIdPattern.*"
1 Like