can't load xml file in wx python RichtextCtrl

Iam new to wxpython. iam trying to load xml in richtextctrl but it’s showing blank. iam using richtextctrl for display xml and images.

class TestFrame(wx.Frame):

def init(self, parent):

wx.Frame.init(self, parent, -1, “A Grid”, size=(500, 300))

panel = wx.Panel(self, -1)

self.__editor = editor = self.rtc = rt.RichTextCtrl(self, wx.ID_ANY, pos=wx.DefaultPosition, size=(390, 388), style=0);

bsizer = wx.BoxSizer()

bsizer.Add(editor, 1, wx.EXPAND)

self.SetSizerAndFit(bsizer)

self.rtc.Freeze()

xml_file = open(“E:/books.xml”, “r”)

xml = xml_file.read()

xml_file.close()

handler = rt.RichTextXMLHandler()

handler.SetFlags(rt.RICHTEXT_HANDLER_INCLUDE_STYLESHEET)

rt_buffer = self.rtc.GetBuffer()

#rt_buffer.AddHandler(handler)

output = StringIO(xml);

handler.LoadStream(rt_buffer, output)

self.rtc.Refresh()

self.rtc.Thaw()

app = wx.App()

frame = TestFrame(None)

frame.Show(True)

app.MainLoop()

and i tried following method also. but still no result.

self.rtc.GetBuffer().AddHandler(rt.RichTextXMLHandler())

stream = StringIO(xml);

rt_buffer = self.rtc.GetBuffer()

rt_buffer.LoadStream(stream, rt.RICHTEXT_TYPE_XML)

please tell me what is missing here.

Nagarajan Babu wrote:

Iam new to wxpython. iam trying to load xml in richtextctrl but it's
showing blank. iam using richtextctrl for display xml and images.

I want to make sure you understand that the XML handler for the
RichTextCtrl is not intended as a general-purpose XML renderer. The
only XML you can load is XML that has been previously saved from an
RTC. It has to follow the RTC DTD.

As an experiment, try doing
    editor.AppendText( "This is some text" )
and instead of loading your content, try:
    handler.SaveFile( rt_buffer, "lookatme.xml" )

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

I got it now. Thanks.

···

On Monday, September 8, 2014 10:53:37 PM UTC+5:30, Tim Roberts wrote:

Nagarajan Babu wrote:

Iam new to wxpython. iam trying to load xml in richtextctrl but it’s

showing blank. iam using richtextctrl for display xml and images.

I want to make sure you understand that the XML handler for the

RichTextCtrl is not intended as a general-purpose XML renderer. The

only XML you can load is XML that has been previously saved from an

RTC. It has to follow the RTC DTD.

As an experiment, try doing

editor.AppendText( "This is some text" )

and instead of loading your content, try:

handler.SaveFile( rt_buffer, "lookatme.xml" )


Tim Roberts, ti...@probo.com

Providenza & Boekelheide, Inc.