I need to generate an XML file in bash(I am new to bash/scripting languages, despite working on C/C++/UNIX for some time). Right now, I am generating something like this, which is pretty flat
st='<'
et='>'
sl='/'
-------------------
stag() {
text=$st$1$et
echo $text >> output_file
}
--------------------
etag() {
text=$sl$1
stag $text
}
--------------------
attr() {
text=$1
echo $text >> output_file
}
--------------------
#--Function Call
stag "tag"
attr "xml"
etag "tag"
--------------------
#--output
<tag>xml</tag>
In this, I feel there are lots of chance to make errors and after coding in C++ for so long, I think there should be a better structured way to code.... Any thoughts is appreciated.... or any material you think, I should learn first, plz post here.... Thanks...