how to gen XML?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to gen XML?
# 1  
Old 04-19-2009
how to gen XML?

hi Everyone,

I am here would like to ask about generate XML.

here is the content should print in XML...
Response XML:
Code:
<?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

Last edited by Yogesh Sawant; 04-20-2009 at 05:28 AM.. Reason: added code tags
# 2  
Old 04-20-2009
i am not sure if i understand your question quite clearly..sorry. please elaborate on exactly what u wwant to achieve?


cheers,
Devaraj Takhellambam
# 3  
Old 04-20-2009
I need to generate the xml with content below, what is the method?
Response XML:
Code:
<?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.

Code:
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

Last edited by Yogesh Sawant; 04-20-2009 at 05:26 AM.. Reason: added code tags
# 4  
Old 04-20-2009
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
# 5  
Old 04-20-2009
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
# 6  
Old 04-20-2009
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
# 7  
Old 04-28-2009
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
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. What is on Your Mind?

New-gen gaming consoles

I've been thinking of buying a gaming console. I've narrowed down to two options and of course they are Sony PS3 and XBOX 360. Both have equally good reviews. Most games are released for both PS3 as well as XBOX. I did search the forums for a similar thread and found this. The highest number of... (8 Replies)
Discussion started by: balajesuri
8 Replies

2. Programming

Problem with csv file gen from C++

Hi Frnds, I have a problem with csv file gen. Here is the description: My code genereates a csv file as output in which a particular column("OUTPUT NUMBER")contains a string value fetched from db. Now the problem is when i open this csv file the OUTPUT NUMBER column misses the zero("0")... (10 Replies)
Discussion started by: electroon
10 Replies
Login or Register to Ask a Question