我有一个工作正常的API。我提取看起来像这样的XML数据:
<?xml version="1.0" encoding="UTF-8"?>
<buildings>
<size>
7
</size>
<building>
<id>
1
</id>
<name>
First Building
</name>
</building>
<building>
<id>
2
</id>
<name>
Second Building
</name>
</building>
</buildings>
尝试将每个建筑物的名称打印为
First Building
Second Building
我尝试过:
IDS=$(*fullcommand* | awk -F'>|<' '/<name>/ {print $3}')
printf '%s\n' $IDS
但此打印:
First
Building
Second
Building
任何帮助都会很棒。谢谢
如果要在“名称”和“ /名称”之间切出
sed -n '/<name>/,/<\/name>/p' | grep -v '^ *<' | sed 's/^ *//'