Results 1 to 2 of 2
Hallo,
I am a newbie here, i hope somebody can help me.
I am trying to read an xml file and use some of its information
The xml file contains ...
- 01-31-2010 #1Just Joined!
- Join Date
- Jan 2010
- Posts
- 1
bash script with array
Hallo,
I am a newbie here, i hope somebody can help me.
I am trying to read an xml file and use some of its information
The xml file contains multiple adresses
These adresses contain multiple words (for example "Oude Gracht 12"
<afl_var_adres>Oude Gracht 12</afl_var_adres>
What i have so far
I read the xml file and put the data in an array
adres=`awk '/<afl_var_adres>/ {stp=index($0,">")+1; \
newstr=substr($0,stp); \
etp=index(newstr,"<")-1; \
print substr(newstr,0,etp); \
}' $xmlfile`
L_ARRAY=( `echo ${adres}` )
What happens all the words from 1 line (Oude Gracht 12) are filled in L_Array[0], L_Array[1] and L_Array[2]
echo $L_Array[0] outputs "Oude"
echo $L_Array[1] outputs "Gracht"
echo $L_Array[2] outputs "12"
I would like to have the full address in one array field
like:
echo $L_Array[0]
outputs:
Oude Gracht 12
Anyone any suggestion
Thanks in advance
- 01-31-2010 #2Linux User
- Join Date
- Nov 2009
- Location
- France
- Posts
- 292
With test data, the above writings did what you want. Don't know how and why for the first writing above, neither for the splitting that happened the way you wrote. If someone could explain, that would be great !Code:L_ARRAY=$(echo ${adres}) or L_ARRAY=${adres}0 + 1 = 1 != 2 <> 3 != 4 ...
Until the camel can pass though the eye of the needle.


Reply With Quote