ryanW
April 19, 2009, 10:48pm
1
hi Everyone,
I am here would like to ask about generate XML.
here is the content should print in XML...
Response XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response scannerId="888888" success="true" userId="444" xmlns="404 - Not Found">
<locInfo>
<location>SHE </location>
<locType>P</locType>
<warehouse>MRT </warehouse>
<timeout>188</timeout>
</locInfo>
</response>
in this case.. how to write into testing.xml? is it possible can use echo to print it to xml? i try is working but, seen like the method not correct at all..
Hope anyone of u can guide me..
thankx
Thank you
i am not sure if i understand your question quite clearly..sorry. please elaborate on exactly what u wwant to achieve?
cheers,
Devaraj Takhellambam
ryanW
April 19, 2009, 11:36pm
3
I need to generate the xml with content below, what is the method?
Response XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response scannerId="888888" success="true" userId="444" xmlns="404 - Not Found">
<locInfo>
<location>SHE </location>
<locType>P</locType>
<warehouse>MRT </warehouse>
<timeout>188</timeout>
</locInfo>
</response>
This is my current coding... but look like not a good method.
echo "Response XML: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>" >> testing.xml
echo "<response scannerId="239198" success="true" userId="123" xmlns="404 - Not Found">" >> testing.xml
echo " <locInfo>" >> testing.xml
echo " <location>SHE </location>" >> testing.xml
echo " <locType>P</locType>" >> testing.xml
echo " <warehouse>MRT </warehouse>" >> testing.xml
echo " <timeout>188</timeout>" >> testing.xml
echo " </locInfo>" >> testing.xml
echo "</response>" >> testing.xml
I hope someone can teach me a good method to write this content to xml file...
thankx
put a single quote and not double. doule quote will evalute/expand the metachrecters if present inside the string.
echo 'Response XML: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>' >> testing.xml
cheers,
Devaraj Takhellambam
ryanW
April 19, 2009, 11:46pm
5
it is correct to put "echo" to every single line? got any method which to use only one "echo"? or other than "echo" method? not proffesional enough if i use so many "echo"...
thankx
I am sure you would be having a file from which u want to generate the xml.
u need to understand the file, use unix commands like sed, etc and generate the xml. u might probably want to share the file if u have it.
cheers,
Devaraj Takhellambam
try this
cat >> testing.xml << EOF
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response scannerId="888888" success="true" userId="444" xmlns="404 - Not Found">
<locInfo>
<location>SHE </location>
<locType>P</locType>
<warehouse>MRT </warehouse>
<timeout>188</timeout>
</locInfo>
</response>
EOF