Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > FW: [Jython-users] ERROR : parsing xml in jython

Reply
Thread Tools

FW: [Jython-users] ERROR : parsing xml in jython

 
 
Divya Prakash
Guest
Posts: n/a
 
      12-19-2006
Hi

But I am unable to parse all the nodes of the tree .....especially the
subtree of the main tree

It displays only the sibling not the subtree


Regards
Divya

-----Original Message-----
From: Matthias Berth [(E-Mail Removed)]
Sent: Tuesday, December 19, 2006 3:18 PM
To: Divya Prakash
Subject: Re: [Jython-users] ERROR : parsing xml in jython

Hi,

looks like you have to make an InputSource from the file, like so:


from java.io import File, FileReader, StringReader

textReader = FileReader(File(filename))
inputSource = InputSource(textReader)
dp.parse(inputSource)

Hope this helps

Matthias

Divya Prakash schrieb:

> Hi All,
>
>
>
> I m facing the problem while parsing xml file ..
>
>
>
> My code is :-
>
>
>
>
>
> import sys
>
> from org.apache.xerces.parsers import DOMParser as dp
>
> import javax.xml.parsers
>
> infilename = open("mos.xml","r")
>
> print infilename


> def test(infilename):
>
> """Parse XML document and show attributes and names.
>
> """
>
> print infilename
>
> parser = dp()
>
> print parser
>
> gh = parser.parse(infilename)
>
> print gh
>
> doc = parser.getDocument()
>
> node = doc.getFirstChild()
>
> print "Attributes:"
>
> show_attrs(node)
>
> print "Names:"
>
> show_names(node)
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What libraries should I use for MIME parsing, XML parsing, and MySQL ? John Levine Ruby 0 02-02-2012 11:15 PM
FW: [Jython-users] Jython Licensing Question Pinegar, Kent T Python 0 07-24-2008 01:38 PM
Different results parsing a XML file with XML::Simple (XML::Sax vs. XML::Parser) Erik Wasser Perl Misc 5 03-05-2006 10:09 PM
Print XML parsing to JspWriter (out) Class org.xml.sax.helpers.NewInstance can not access a member of class javax.xml.parsers.SAXParser with modifiers "protected" Per Magnus L?vold Java 0 11-15-2004 02:27 PM
[Jython-users] ANN: SPIRO - a cPython->Jython bridge (amongst otheruses) David McNab Python 0 04-09-2004 10:20 AM



Advertisments