Unix Shell - Selecting from XML using sed/awk

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2005 > Selecting from XML using sed/awk





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Selecting from XML using sed/awk
Jens P

2005-09-16, 6:01 pm

I have a huge XML file from which I need to select sections like:

<un:Cell id="404181">
<un:attributes>
<un:userLabel>Cell 404181</un:userLabel>
<un:cId>41812</un:cId>
...
.... variable number of lines....
.....
</un:attributes>
<xn:VsDataContainer id="404181">
<xn:attributes>

<xn:vsDataType>vsDataCell</xn:vsDataType>
<es:vsDataCell>
<es:tCell>0</es:tCell>
...
.... variable number of lines....
.....
<es:cellReserved>1</es:cellReserved>
<es:treSelection>2</es:treSelection>
</es:vsDataCell>
</xn:attributes>
</xn:VsDataContainer>
...
.... variable number of lines....
.....
</un:Cell>

I.e. I need the all lines inbetween "<un:Cell id=" and ending with
"</un:Cell>" !
Note the number of lines may vary....

And another variant where the same section is selected but a part, e.g. from
<un:attributes> to </un:attributes> is omitted would be helpful...!

I guess this is relatively easy to do with sed or awk - for someone more
experienced than me...!
Any help will be appreciated...!

Thanks!

BR, Jens


Loki Harfagr

2005-09-16, 6:01 pm

Le Fri, 16 Sep 2005 17:16:15 +0200, Jens P a écrit_:

> I have a huge XML file from which I need to select sections like:
>
> <un:Cell id="404181">
> <un:attributes>
> <un:userLabel>Cell 404181</un:userLabel>
> <un:cId>41812</un:cId>
> ...
> .... variable number of lines....
> .....
> </un:attributes>
> <xn:VsDataContainer id="404181">
> <xn:attributes>
>
> <xn:vsDataType>vsDataCell</xn:vsDataType>
> <es:vsDataCell>
> <es:tCell>0</es:tCell>
> ...
> .... variable number of lines....
> .....
> <es:cellReserved>1</es:cellReserved>
> <es:treSelection>2</es:treSelection>
> </es:vsDataCell>
> </xn:attributes>
> </xn:VsDataContainer>
> ...
> .... variable number of lines....
> .....
> </un:Cell>
>
> I.e. I need the all lines inbetween "<un:Cell id=" and ending with
> "</un:Cell>" !
> Note the number of lines may vary....
>
> And another variant where the same section is selected but a part, e.g. from
> <un:attributes> to </un:attributes> is omitted would be helpful...!
>
> I guess this is relatively easy to do with sed or awk - for someone more
> experienced than me...!
> Any help will be appreciated...!


As you didn't precised which shell or awk, I'll start
with gawk :-)

This should be a way :

$ awk '/<un:Cell id=/,/<\/un:Cell>$/{print}' yourfile

And for the variant, let's be lazy :

$ awk '/<un:Cell id=/,/<\/un:Cell>$/' yourfile | awk
'/<un:attributes>/,/<\/un:attributes>/{next};1'

Jens P

2005-09-16, 6:01 pm

Thanks, will try this out....

I am running Solaris 8, so Bourne shell and Solaris standard awk, sed....

BR, Jens

>
> As you didn't precised which shell or awk, I'll start
> with gawk :-)
>
> This should be a way :
>
> $ awk '/<un:Cell id=/,/<\/un:Cell>$/{print}' yourfile
>
> And for the variant, let's be lazy :
>
> $ awk '/<un:Cell id=/,/<\/un:Cell>$/' yourfile | awk
> '/<un:attributes>/,/<\/un:attributes>/{next};1'
>



Jens P

2005-09-16, 6:01 pm

Hi Loki,

The first one worked fine, but the variant gave an error message:

awk: syntax error near line 1
awk: bailing out near line 1


Could that be due to the sixe of the file? (400 MB)

BR, Jens



> This should be a way :
>
> $ awk '/<un:Cell id=/,/<\/un:Cell>$/{print}' yourfile
>
> And for the variant, let's be lazy :
>
> $ awk '/<un:Cell id=/,/<\/un:Cell>$/' yourfile | awk
> '/<un:attributes>/,/<\/un:attributes>/{next};1'
>



Loki Harfagr

2005-09-16, 6:01 pm

Le Fri, 16 Sep 2005 19:48:53 +0200, Jens P a écrit_:

> Hi Loki,


Hello, please avoid top-posting here :D)

> The first one worked fine,


Nice !-)

> but the variant gave an error message:


Er :-(

> awk: syntax error near line 1
> awk: bailing out near line 1


Are you certain that it's not a typo or an error from
the cutpaste ? (if you use PuTty for instance there are some
issues when crossing systems)

> Could that be due to the sixe of the file? (400 MB)


Well, I don't think so, and BTW we were lucky I choose the
"lazy" option.
[vbcol=seagreen]


It may be caused by the "facility" in using '1' as a print trigger,
if so just try this :

$ awk '/<un:Cell id=/,/<\/un:Cell>$/' yourfile | awk '/<un:attributes>/,/<\/un:attributes>/{next};{print}'

Ed Morton

2005-09-16, 6:01 pm



Loki Harfagr wrote:
> Le Fri, 16 Sep 2005 19:48:53 +0200, Jens P a écrit :
>
>
>
>
> Hello, please avoid top-posting here :D)
>
>
>
>
> Nice !-)
>
>
>
>
> Er :-(
>
>
>
>
> Are you certain that it's not a typo or an error from
> the cutpaste ?


No, he's using old, broken awk.

For the OP, switch to gawk, or nawk or /usr/xpg4/bin/awk (on Solaris).
William Park

2005-09-17, 2:48 am

Jens P <jens.pedersenXXXX@ericsson.com> wrote:
> I have a huge XML file from which I need to select sections like:
>
> <un:Cell id="404181">

....
> </un:Cell>
>
> I.e. I need the all lines inbetween "<un:Cell id=" and ending with
> "</un:Cell>" !
> Note the number of lines may vary....


Usually,
sed -n '/<un:Cell /,/<\/un:Cell>/p'
should do the trick. If the patterns are not on a line by themselves,
then modify the input so that they are.

--
William Park <opengeometry@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
Jens P

2005-09-19, 7:50 am

For the variant using /usr/xpg4/bin/awk in Solaris does not give any errors
(Thanks Ed), but Loki's suggested awk statement does not work the way it
should.

My input file contains a number "main" sections starting with <un:Cell id=/
and ending with /un:Cell. Selecting these sections work well, but I want to
leave out a number of subsections within each "main" section. These start
and end with e.g. <un:attributes> and </un:attributes> or <es:test> and
</es:test>. There could be many of these subsections and there could be a
number of different type of subsections to leave out. How is this done?

The variant below does not leave out anything as far as I can see......

BR, Jens
[vbcol=seagreen]


It may be caused by the "facility" in using '1' as a print trigger,
if so just try this :

$ awk '/<un:Cell id=/,/<\/un:Cell>$/' yourfile | awk
'/<un:attributes>/,/<\/un:attributes>/{next};{print}'





Loki Harfagr

2005-09-19, 7:50 am

Le Mon, 19 Sep 2005 13:54:14 +0200, Jens P a écrit_:

> For the variant using /usr/xpg4/bin/awk in Solaris does not give any errors
> (Thanks Ed), but Loki's suggested awk statement does not work the way it
> should.


This puzzles me.
I'll test it on /usr/xpg4/bin/awk in a moment to see if it's related
or if it is because the real data includes traps unlike the sample given
....

> My input file contains a number "main" sections starting with <un:Cell
> id=/ and ending with /un:Cell. Selecting these sections work well, but I
> want to leave out a number of subsections within each "main" section.
> These start and end with e.g. <un:attributes> and </un:attributes> or
> <es:test> and </es:test>. There could be many of these subsections and
> there could be a number of different type of subsections to leave out.
> How is this done?


Sincerely, using the same principles it *should* work :

$ awk '/<un:Cell id=/,/<\/un:Cell>$/' xmlmess.txt |
awk '/<un:attributes>/,/<\/un:attributes>/{next};
/<es:test>/,/<\/es:test>/{next};
/<xn:VsDataContainer /,/<\/xn:VsDataContainer>/{next};
{print}'

(caution: I put a pattern for "<xn:VsDataContainer" in this
sample, just to show you how to extend the rules set)


> The variant below does not leave out anything as far as I can see......
>

....

Ok, i'll check on my Sun boxes, meanwhile if you can put somewhere on
the Net a sample file of your data that demonstrates the failure for
the expressions we tried, and post the URL here, it'd be easier to find
out what can the errors possibly come from.
And a file of the *wanted* output for this sample woud help to
see if it is just that we forgot something in your hopes ;-)

Loki Harfagr

2005-09-19, 6:02 pm

Le Mon, 19 Sep 2005 13:54:14 +0200, Jens P a écrit_:

> For the variant using /usr/xpg4/bin/awk in Solaris does not give any errors
> (Thanks Ed), but Loki's suggested awk statement does not work the way it
> should.


I just tested on this type of machine :
# uname -srvi
SunOS 5.8 Generic_108528-21 SUNW,Sun-Fire-280R

the expressions :
awk '/<un:Cell id=/,/<\/un:Cell>$/' yourfile |
awk '/<un:attributes>/,/<\/un:attributes>/{next};
/<es:test>/,/<\/es:test>/{next};
/<xn:VsDataContainer /,/<\/xn:VsDataContainer>/{next};
{print}'

and the normal first :
# awk '/<un:Cell id=/,/<\/un:Cell>$/' yourfile |
awk '/<un:attributes>/,/<\/un:attributes>/{next};
/<es:test>/,/<\/es:test>/{next};
{print}'


with :

-rwxr-xr-x 2 bin bin 1152192 Aug 29 2004 /opt/local/bin/gawk
-r-xr-xr-x 2 root bin 85828 Jan 6 2000 /usr/bin/awk
-r-xr-xr-x 1 root bin 121300 Mar 12 2002 /usr/bin/nawk
-r-xr-xr-x 1 root bin 71360 Jan 5 2000 /usr/xpg4/bin/awk

the gawk is a 3.1.4, I don't know the versions of the others
and they dont like the --version switch but the dates should give an idea ;-)


There the results are :
Every tests gives the expected result !
anecdotically, only gawk likes the '1' instead of {print}, well, we kew it...

Then, I suspect that I didn't understand what you wanted as a result
or that the real data fires some logic holes ?


Ed Morton

2005-09-19, 6:02 pm



Loki Harfagr wrote:
<snip>
> with :
>
> -rwxr-xr-x 2 bin bin 1152192 Aug 29 2004 /opt/local/bin/gawk
> -r-xr-xr-x 2 root bin 85828 Jan 6 2000 /usr/bin/awk
> -r-xr-xr-x 1 root bin 121300 Mar 12 2002 /usr/bin/nawk
> -r-xr-xr-x 1 root bin 71360 Jan 5 2000 /usr/xpg4/bin/awk
>
> the gawk is a 3.1.4, I don't know the versions of the others
> and they dont like the --version switch but the dates should give an idea ;-)
>
>
> There the results are :
> Every tests gives the expected result !
> anecdotically, only gawk likes the '1' instead of {print}, well, we kew it...


No, all but old, broken awk would be fine with that. For example with:

-rwxrwxr-x 1 exptools exptools 281156 Jan 20 2005 /opt/exp/gnu/bin/gawk
-r-xr-xr-x 2 root bin 85828 Jan 5 2000 /usr/bin/awk
-r-xr-xr-x 1 root bin 121300 Mar 12 2002 /usr/bin/nawk
-r-xr-xr-x 1 root bin 71360 Jan 5 2000 /usr/xpg4/bin/awk

I get:

$ echo "a" | /usr/xpg4/bin/awk '{printf "$0 is "}1'
$0 is a
$ echo "a" | nawk '{printf "$0 is "}1'
$0 is a
$ echo "a" | gawk '{printf "$0 is "}1'
$0 is a
$ echo "a" | /usr/bin/awk '{printf "$0 is "}1'
awk: syntax error near line 1
awk: bailing out near line 1

If you're using a newer awk and it's choking on a condition of "1" to
invoke the default action of "print $0", there's some other problem with
your script.

> Then, I suspect that I didn't understand what you wanted as a result
> or that the real data fires some logic holes ?


I have no idea what output the OP is expecting either....

Ed.
bsh

2005-09-22, 2:49 am


Jens P wrote:
> I have a huge XML file from which I need to select sections like:


It sounds as if the correct solution (that is, the most general
one written and debugged by Someone Else ;) is:

A,"XMLparse.awk",1.1,ftp://ftp.freefriends.org/arnold/Aw...2fb62778b31600,$0,"","Steve
Coile" <scoile@csc.com>, "Aharon Robbins" <arnold@skeeve.com>

Although the following are not sed+awk solutions, perhaps you
may get some use out of the following respected software tools:

A,"xpipe.cpp",,http://xpipe.sourceforge.net/,$0,"XML processing"

A,"Xtract.haskell",,http://www.cs.york.ac.uk/fp/Xtract/,$0,"`grep'-like
tool for XML documents (sgrep)","Malcolm Wallace"
<Malcolm.Wallace@cs.york.ac.uk>

A,"sgrep.c;Sgrep",1.92a,http://www.cs.helsinki.fi/u/jjaakko...e/Local/Sgrep/,$0,"Structured
Grep","Jani Jaakkola" <jjaakkol@cs.helsinki.fi>, "Pekka Kilpela:inen"
<Pekka.Kilpelainen@helsinki.fi>

=Brian

Jens P

2005-09-22, 9:01 pm

First, thansk for your time and interest and sorry I was not clear on this!

The full XML file is quite large (500 MB) and consists of thousands of
sections like the one below. Each "<un:UtranCell" section contains a number
of "subsections" (nodes) starting with <un:attributes>, <un:UtranRelation,
<gn:GsmRelation id etc. This number may be varable...


<un:UtranCell id="404181">
<un:attributes>
<un:userLabel>UtranCell
404181</un:userLabel>
<un:cId>4181</un:cId>
<un:localCellId>404181</un:localCellId>
<un:uarfcnUl>9837</un:uarfcnUl>
<un:uarfcnDl>10787</un:uarfcnDl>

<un:primaryScramblingCode>109</un:primaryScramblingCode>

<un:primaryCpichPower>375</un:primaryCpichPower>

<un:maximumTransmissionPower>440</un:maximumTransmissionPower>

<un:primarySchPower>-58</un:primarySchPower>

<un:secondarySchPower>-75</un:secondarySchPower>
<un:bchPower>-71</un:bchPower>
<un:lac>24</un:lac>
<un:rac>1</un:rac>
<un:sac>4181</un:sac>

<un:utranCellIubLink>18</un:utranCellIubLink>
</un:attributes>
<xn:VsDataContainer id="404181">
<xn:attributes>

<xn:vsDataType>vsDataUtranCell</xn:vsDataType>

<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>

<es:interFreqFddMeasIndicator>0</es:interFreqFddMeasIndicator>
<es:sRatSearch>6</es:sRatSearch>
<es:sIntraSearch>0</es:sIntraSearch>
<es:sInterSearch>0</es:sInterSearch>

<es:fachMeasOccaCycLenCoeff>4</es:fachMeasOccaCycLenCoeff>

<es:accessClassNBarred>0</es:accessClassNBarred>

<es:utranCellPosition>0</es:utranCellPosition>

<es:utranCellPosition>5521443</es:utranCellPosition>

<es:utranCellPosition>774052</es:utranCellPosition>

<es:utranCellPosition>0</es:utranCellPosition>

<es:utranCellPosition>5523177</es:utranCellPosition>

<es:utranCellPosition>774866</es:utranCellPosition>

<es:utranCellPosition>0</es:utranCellPosition>

<es:utranCellPosition>5523470</es:utranCellPosition>

<es:utranCellPosition>777246</es:utranCellPosition>

<es:utranCellPosition>0</es:utranCellPosition>

<es:utranCellPosition>5521394</es:utranCellPosition>

<es:utranCellPosition>777807</es:utranCellPosition>

<es:utranCellPosition>0</es:utranCellPosition>

<es:utranCellPosition>5519335</es:utranCellPosition>

<es:utranCellPosition>777193</es:utranCellPosition>

<es:utranCellPosition>0</es:utranCellPosition>

<es:utranCellPosition>5519689</es:utranCellPosition>

<es:utranCellPosition>774824</es:utranCellPosition>
<es:maxTxPowerUl>24</es:maxTxPowerUl>
<es:beMarginAseUl>20</es:beMarginAseUl>
<es:beMarginAseDl>100</es:beMarginAseDl>

<es:sib1PlmnScopeValueTag>19</es:sib1PlmnScopeValueTag>
<es:sf16Adm>16</es:sf16Adm>
<es:beMarginDlPwr>10</es:beMarginDlPwr>
<es:beMarginDlCode>2</es:beMarginDlCode>
<es:hoType>1</es:hoType>

<es:usedFreqThresh2dEcno>-8</es:usedFreqThresh2dEcno>

<es:usedFreqThresh2dRscp>-94</es:usedFreqThresh2dRscp>

<es:administrativeState>1</es:administrativeState>

<es:loadSharingGsmThreshold>0</es:loadSharingGsmThreshold>

<es:loadSharingGsmFraction>0</es:loadSharingGsmFraction>

<es:snDirectedRetryTarget></es:snDirectedRetryTarget>
</xn:attributes>
</xn:VsDataContainer>
<un:UtranRelation id="407732">
<un:attributes>
<un:adjacentCell>2</un:adjacentCell>
</un:attributes>
<xn:VsDataContainer id="407732">
<xn:attributes>

<xn:vsDataType>vsDataUtranRelation</xn:vsDataType>

<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
<es:vsDataUtranRelation>
<es:qOffset1sn>0</es:qOffset1sn>
<es:qOffset2sn>0</es:qOffset2sn>

<es:loadSharingCandidate>0</es:loadSharingCandidate>
</es:vsDataUtranRelation>
</xn:attributes>
</xn:VsDataContainer>
</un:UtranRelation>
<un:UtranRelation id="407683">
<un:attributes>
<un:adjacentCell>3</un:adjacentCell>
</un:attributes>
<xn:VsDataContainer id="407683">
<xn:attributes>

<xn:vsDataType>vsDataUtranRelation</xn:vsDataType>

<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
<es:vsDataUtranRelation>
<es:qOffset1sn>0</es:qOffset1sn>
<es:qOffset2sn>0</es:qOffset2sn>

<es:loadSharingCandidate>0</es:loadSharingCandidate>
</es:vsDataUtranRelation>
</xn:attributes>
</xn:VsDataContainer>
</un:UtranRelation>
<gn:GsmRelation id="T2_D77A">
<gn:attributes>

<gn:adjacentCell> SubNetwork=Utran1_R,ExternalGsmCell=T2_D
77A</gn:adjacentCel
l>
</gn:attributes>
<xn:VsDataContainer id="T2_D77A">
<xn:attributes>

<xn:vsDataType>vsDataGsmRelation</xn:vsDataType>

<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
<es:vsDataGsmRelation>
<es:qOffset1sn>0</es:qOffset1sn>

<es:mobilityRelationType>0</es:mobilityRelationType>
</es:vsDataGsmRelation>
</xn:attributes>
</xn:VsDataContainer>
</gn:GsmRelation>
<gn:GsmRelation id="T2_592A">
<gn:attributes>

<gn:adjacentCell> SubNetwork=Utran1_R,ExternalGsmCell=T2_5
92A</gn:adjacentCel
l>
</gn:attributes>
<xn:VsDataContainer id="T2_592A">
<xn:attributes>

<xn:vsDataType>vsDataGsmRelation</xn:vsDataType>

<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
<es:vsDataGsmRelation>
<es:qOffset1sn>0</es:qOffset1sn>

<es:mobilityRelationType>0</es:mobilityRelationType>
</es:vsDataGsmRelation>
</xn:attributes>
</xn:VsDataContainer>
</gn:GsmRelation>
<gn:GsmRelation id="T2_D75B">
<gn:attributes>

<gn:adjacentCell> SubNetwork=Utran1_R,ExternalGsmCell=T2_D
75B</gn:adjacentCel
l>
</gn:attributes>
<xn:VsDataContainer id="T2_D75B">
<xn:attributes>

<xn:vsDataType>vsDataGsmRelation</xn:vsDataType>

<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
<es:vsDataGsmRelation>
<es:qOffset1sn>0</es:qOffset1sn>

<es:mobilityRelationType>0</es:mobilityRelationType>
</es:vsDataGsmRelation>
</xn:attributes>
</xn:VsDataContainer>
</gn:GsmRelation>
<gn:GsmRelation id="T2_593B">
<gn:attributes>

<gn:adjacentCell> SubNetwork=Utran1_R,ExternalGsmCell=T2_5
93B</gn:adjacentCel
l>
</gn:attributes>
<xn:VsDataContainer id="T2_593B">
<xn:attributes>

<xn:vsDataType>vsDataGsmRelation</xn:vsDataType>

<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
<es:vsDataGsmRelation>
<es:qOffset1sn>0</es:qOffset1sn>

<es:mobilityRelationType>0</es:mobilityRelationType>
</es:vsDataGsmRelation>
</xn:attributes>
</xn:VsDataContainer>
</gn:GsmRelation>
</un:UtranCell>

In this example what I was is the the whole <UtranCell: -> </un:UtranCell>
section, but without the <gn:GsmRelation and <un:UtranRelation
subsections/nodes of the file.

BR, Jens


"Loki Harfagr" <loki@DarkDesign.free.fr> wrote in message
news:432eb97d$0$26351$626a14ce@news.free.fr...
> Le Mon, 19 Sep 2005 13:54:14 +0200, Jens P a écrit :
>
errors[vbcol=seagreen]
>
> I just tested on this type of machine :
> # uname -srvi
> SunOS 5.8 Generic_108528-21 SUNW,Sun-Fire-280R
>
> the expressions :
> awk '/<un:Cell id=/,/<\/un:Cell>$/' yourfile |
> awk '/<un:attributes>/,/<\/un:attributes>/{next};
> /<es:test>/,/<\/es:test>/{next};
> /<xn:VsDataContainer /,/<\/xn:VsDataContainer>/{next};
> {print}'
>
> and the normal first :
> # awk '/<un:Cell id=/,/<\/un:Cell>$/' yourfile |
> awk '/<un:attributes>/,/<\/un:attributes>/{next};
> /<es:test>/,/<\/es:test>/{next};
> {print}'
>
>
> with :
>
> -rwxr-xr-x 2 bin bin 1152192 Aug 29 2004 /opt/local/bin/gawk
> -r-xr-xr-x 2 root bin 85828 Jan 6 2000 /usr/bin/awk
> -r-xr-xr-x 1 root bin 121300 Mar 12 2002 /usr/bin/nawk
> -r-xr-xr-x 1 root bin 71360 Jan 5 2000 /usr/xpg4/bin/awk
>
> the gawk is a 3.1.4, I don't know the versions of the others
> and they dont like the --version switch but the dates should give an idea

;-)
>
>
> There the results are :
> Every tests gives the expected result !
> anecdotically, only gawk likes the '1' instead of {print}, well, we kew

it...
>
> Then, I suspect that I didn't understand what you wanted as a result
> or that the real data fires some logic holes ?
>
>



Loki Harfagr

2005-09-22, 9:01 pm

Le Thu, 22 Sep 2005 15:27:58 +0200, Jens P a écrit_:

> First, thansk for your time and interest and sorry I was not clear on this!
>


Don't worry, you're welcome !

> The full XML file is quite large (500 MB) and consists of thousands of
> sections like the one below. Each "<un:UtranCell" section contains a
> number of "subsections" (nodes) starting with <un:attributes>,
> <un:UtranRelation, <gn:GsmRelation id etc. This number may be varable...
>
>
> <un:UtranCell id="404181">


Allright, let's roll again ;-)

(sorry, I here snip off most of lines to avoid growing too fat a post)
....

Let's see if you'd like this result I get with the script below, and
if it not yet what you want please comment about what and where :D)

If the output shown below is what you want and it doesn't work
on your system we'll just have to find how to rewrite the script
a little bit more compatible to your tools :-)
If the output is not what you want do your best to show us what's wrong
compared to your expectations and we'll do our best to adapt !

(note: I decided here to erase the empty lines to shorten the post but you
can test and keep them if you use this instead : $ awk '/<un:UtranCell
id=/,/<\/un:UtranCell>$/' xmlmess2.txt | awk '/<gn:GsmRelation
id=/,/<\/gn:GsmRelation>/{next};{print}'
)

$ awk '/^$/{next} /<un:UtranCell id=/,/<\/un:UtranCell>$/' xmlmess2.txt | awk '/<gn:GsmRelation id=/,/<\/gn:GsmRelation>/{next};{print}'
<un:UtranCell id="404181">
<un:attributes>
<un:userLabel>UtranCell
404181</un:userLabel>
<un:cId>4181</un:cId>
<un:localCellId>404181</un:localCellId>
<un:uarfcnUl>9837</un:uarfcnUl>
<un:uarfcnDl>10787</un:uarfcnDl>
<un:primaryScramblingCode>109</un:primaryScramblingCode>
<un:primaryCpichPower>375</un:primaryCpichPower>
<un:maximumTransmissionPower>440</un:maximumTransmissionPower>
<un:primarySchPower>-58</un:primarySchPower>
<un:secondarySchPower>-75</un:secondarySchPower>
<un:bchPower>-71</un:bchPower>
<un:lac>24</un:lac>
<un:rac>1</un:rac>
<un:sac>4181</un:sac>
<un:utranCellIubLink>18</un:utranCellIubLink>
</un:attributes>
<xn:VsDataContainer id="404181">
<xn:attributes>
<xn:vsDataType>vsDataUtranCell</xn:vsDataType>
<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
<es:interFreqFddMeasIndicator>0</es:interFreqFddMeasIndicator>
<es:sRatSearch>6</es:sRatSearch>
<es:sIntraSearch>0</es:sIntraSearch>
<es:sInterSearch>0</es:sInterSearch>
<es:fachMeasOccaCycLenCoeff>4</es:fachMeasOccaCycLenCoeff>
<es:accessClassNBarred>0</es:accessClassNBarred>
<es:utranCellPosition>0</es:utranCellPosition>
<es:utranCellPosition>5521443</es:utranCellPosition>
<es:utranCellPosition>774052</es:utranCellPosition>
<es:utranCellPosition>0</es:utranCellPosition>
<es:utranCellPosition>5523177</es:utranCellPosition>
<es:utranCellPosition>774866</es:utranCellPosition>
<es:utranCellPosition>0</es:utranCellPosition>
<es:utranCellPosition>5523470</es:utranCellPosition>
<es:utranCellPosition>777246</es:utranCellPosition>
<es:utranCellPosition>0</es:utranCellPosition>
<es:utranCellPosition>5521394</es:utranCellPosition>
<es:utranCellPosition>777807</es:utranCellPosition>
<es:utranCellPosition>0</es:utranCellPosition>
<es:utranCellPosition>5519335</es:utranCellPosition>
<es:utranCellPosition>777193</es:utranCellPosition>
<es:utranCellPosition>0</es:utranCellPosition>
<es:utranCellPosition>5519689</es:utranCellPosition>
<es:utranCellPosition>774824</es:utranCellPosition>
<es:maxTxPowerUl>24</es:maxTxPowerUl>
<es:beMarginAseUl>20</es:beMarginAseUl>
<es:beMarginAseDl>100</es:beMarginAseDl>
<es:sib1PlmnScopeValueTag>19</es:sib1PlmnScopeValueTag>
<es:sf16Adm>16</es:sf16Adm>
<es:beMarginDlPwr>10</es:beMarginDlPwr>
<es:beMarginDlCode>2</es:beMarginDlCode>
<es:hoType>1</es:hoType>
<es:usedFreqThresh2dEcno>-8</es:usedFreqThresh2dEcno>
<es:usedFreqThresh2dRscp>-94</es:usedFreqThresh2dRscp>
<es:administrativeState>1</es:administrativeState>
<es:loadSharingGsmThreshold>0</es:loadSharingGsmThreshold>
<es:loadSharingGsmFraction>0</es:loadSharingGsmFraction>
<es:snDirectedRetryTarget></es:snDirectedRetryTarget>
</xn:attributes>
</xn:VsDataContainer>
<un:UtranRelation id="407732">
<un:attributes>
<un:adjacentCell>2</un:adjacentCell>
</un:attributes>
<xn:VsDataContainer id="407732">
<xn:attributes>
<xn:vsDataType>vsDataUtranRelation</xn:vsDataType>
<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
<es:vsDataUtranRelation>
<es:qOffset1sn>0</es:qOffset1sn>
<es:qOffset2sn>0</es:qOffset2sn>
<es:loadSharingCandidate>0</es:loadSharingCandidate>
</es:vsDataUtranRelation>
</xn:attributes>
</xn:VsDataContainer>
</un:UtranRelation>
<un:UtranRelation id="407683">
<un:attributes>
<un:adjacentCell>3</un:adjacentCell>
</un:attributes>
<xn:VsDataContainer id="407683">
<xn:attributes>
<xn:vsDataType>vsDataUtranRelation</xn:vsDataType>
<xn:vsDataFormatVersion>SpecificAttributes.3.0</xn:vsDataFormatVersion>
<es:vsDataUtranRelation>
<es:qOffset1sn>0</es:qOffset1sn>
<es:qOffset2sn>0</es:qOffset2sn>
<es:loadSharingCandidate>0</es:loadSharingCandidate>
</es:vsDataUtranRelation>
</xn:attributes>
</xn:VsDataContainer>
</un:UtranRelation>
</un:UtranCell>

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com