About shell script to check well formedness of XML


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting About shell script to check well formedness of XML
# 1  
Old 09-02-2008
Error About shell script to check well formedness of XML

HI team,

I want to write a shell script to check weather a xml is in well from or not ? but i didn't get any infromation regarding this. i got some python script however its not working well in unix server. it would be grateful to me if yoiu people can help me to sort out this ...Smilie
############################################

i try with this python script while importing the header it got stuck up...
Smilie



#!/usr/bin/env python

from xml.parsers.xmlproc import xmlval
import sys

def parseFile(file):
parser=xmlval.XMLValidator()
parser.parse_resource(file)

if len(sys.argv) != 2:
print '''Usage:

python %s filename

''' % sys.argv[0]
sys.exit(0)

file=sys.argv[1]
#f=open(file)

try:
parseFile(file)
print "%s is well-formed and valid" % file

except Exception,e:
print "%s is not well-formed or not valid %s!" % (file, e)


######################################
Error is :

#!/usr/bin/env python
module load python/core/2.5
+ module load python/core/2.5
from xml.parsers.xmlproc import xmlval
+ from xml.parsers.xmlproc import xmlval
Can't open /var/mail/xml.parsers.xmlproc
import sys
+ import sys
Smilie
# 2  
Old 09-02-2008
You have libraries and commands already doing the same.

You could use them.

try xmllint command - it checks for XML well formedness

Or is your question on how to reinvent that so that you could learn how is it actually done ?
# 3  
Old 11-21-2008
using variable in sed command

HI,

i need to use a variable in sed command to print a particular line

i tried sed -n ' "$Var"p ' abc.txt

but it is not working please help me to use a variable in the sed......Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing XML using shell script

Well, issue is i have to parse this script to get the VERSION: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleAllowMixedLocalizations</key> ... (9 Replies)
Discussion started by: zorosinister
9 Replies

2. Shell Programming and Scripting

Shell program to check if the same text appears twice in an XML file

Hi All, I am very new to this forum and beginner to shell scripting. I need a shell script to: Search for a text in XML file à if the same text appears twice in an XML file à output file name Script should loop thru every xml file of a given folder. Please help me writing this script. ... (1 Reply)
Discussion started by: amardeep001
1 Replies

3. Shell Programming and Scripting

XML parsing using shell script

I have a xml file like this <bul:collectionStrategy name="strategy1"> <bul:collectionTemplateGroup name="15min group"/> <bul:collectionTemplateGroup name="hourly group"/> </bul:collectionStrategy> <bul:CollectionTemplateGroup name="hourly group" > ... (2 Replies)
Discussion started by: LavanyaP
2 Replies

4. Shell Programming and Scripting

Shell script for XML code parsing.

I need to create a shell script that can parse the below XML and send a string back adding all XML values. The text which's not in angular braces are to be printed. Sample code: <RequestBillsRsp... (9 Replies)
Discussion started by: xtatic
9 Replies

5. Shell Programming and Scripting

Shell script for XML code parsing.

Please help me to create a shell script that can parse the below XML and send a string back adding all XML values.:) <RequestBillsRsp... (1 Reply)
Discussion started by: xtatic
1 Replies

6. Shell Programming and Scripting

XML parsing in a shell script.

Below is a XML I have... <?xml version="1.0" encoding="UTF-8" ?> <component xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:XXXXX-www-Install-Manifest manifest.xsd" xmlns="urn:qqqqq-Install-Manifest" name="OM" ... (1 Reply)
Discussion started by: dashok.83
1 Replies

7. Shell Programming and Scripting

Parsing XML using Shell Script

Hello, I'm a starting shell scripter and no Perl knowledge. I've trying to do this for a while: I want to parse an XML file and get certain data out of it and write that data into a CSV file, all this using Shell Scripting (in Bash). Or Perl without any XML Parser/Interpreter (if possible). ... (1 Reply)
Discussion started by: Kage Musha
1 Replies

8. Shell Programming and Scripting

How to remove xml namespace from xml file using shell script?

I have an xml file: <AutoData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Table1> <Data1 10 </Data1> <Data2 20 </Data2> <Data3 40 </Data3> <Table1> </AutoData> and I have to remove the portion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" only. I tried using sed... (10 Replies)
Discussion started by: Gary1978
10 Replies

9. Shell Programming and Scripting

Shell script to map XML nodes

Hi folks, I'm a bit of a novice at this but here goes. I want to read in nodes from an XML file, and map the path to each. eg the file is structured <node><nodename>.</nodename> <node><nodename>topnode</nodename> <node><nodename>subnode1</nodename></node> ... (1 Reply)
Discussion started by: mark14
1 Replies

10. UNIX for Dummies Questions & Answers

generate xml from a shell script

Hello! I would like to generate an xml file from the output of various commands generated from within a shell script (some will be in CDATA). At the moment the only solution I have come up with is echoing xml tags around the commands eg. echo "<bitism>" >> outputfile /usr/sbin/prtconf... (1 Reply)
Discussion started by: speedieB
1 Replies
Login or Register to Ask a Question