Reputation: 11052
I have a xml parser in python by named : NmapParser.py
def nmap_parser_sax(nmap_xml_file):
parser = make_parser()
nmap_parser = NmapParserSAX()
parser.setContentHandler(nmap_parser)
nmap_parser.set_parser(parser)
nmap_parser.set_xml_file(nmap_xml_file)
return nmap_parser
Now i have to call this function from an another file i.e. views.py. I did that
import NmapParser
nmap_parser_sax("/home/lovestone/Desktop/usoc/umit/nmap_example.xml")
print nmap_xml_file
I tried this it shows an following error:
Traceback (most recent call last):
File "parse.py", line 2, in <module>
nmap_parser_sax("/home/lovestone/Desktop/usoc/umit/nmap_example.xml")
NameError: name 'nmap_parser_sax' is not defined
What i have to do is to parse the value from a xml file and then i have to save that value in my java script variable. I am on Django platform.
I also tried this :
import NmapParser
NmapParser.nmap_parser_sax("/home/lovestone/Desktop/usoc/umit/nmap_example.xml")
print nmap_xml_file
and still it is showing same error
Upvotes: 0
Views: 72
Reputation: 304137
you either need to use
from NmapParser import nmap_parser_sax
result = nmap_parser_sax("/home/lovestone/Desktop/usoc/umit/nmap_example.xml")
print result.nmap_xml_file
or
import NmapParser
result = NmapParser.nmap_parser_sax("/home/lovestone/Desktop/usoc/umit/nmap_example.xml")
print result.nmap_xml_file
Upvotes: 1