473,396 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Learning Pyrex with libxml2

Hi, I'm trying to learn how to use Pyrex by converting some of the
libxml2 examples. I'm not having much luck - I can create a document,
but any attempt to create nodes causes a segfault.

The code I'm trying to port is io2.c (http://xmlsoft.org/examples/io2.c)

I've commented the couple lines that cause a problem for me.

thanks,
vic
----
cdef extern from "libxml/tree.h":
ctypedef xmlDocPtr
ctypedef xmlNodePtr
ctypedef xmlNsPtr
xmlDocPtr xmlNewDoc(unsigned char *)
xmlNodePtr xmlNewNode (xmlNsPtr, unsigned char *)
void xmlNodeSetContent (xmlNodePtr, unsigned char *)
xmlNodePtr xmlDocSetRootElement (xmlDocPtr, xmlNodePtr )
void xmlDocDumpFormatMemory (xmlDocPtr, unsigned char **, int *, int )
xmlNodePtr xmlNewChild (xmlNodePtr, xmlNsPtr, unsigned char *,
unsigned char *)
void xmlFreeDoc (xmlDocPtr)
void xmlFree (xmlDocPtr)

def testNewDoc():
cdef xmlNodePtr n
cdef xmlDocPtr doc
cdef unsigned char* xmlbuff
cdef int buffersize

doc = xmlNewDoc(<unsigned char *> "1.0")

## The following three lines cause a segfault
# n = xmlNewNode(None, <unsigned char *> "root")
# xmlNodeSetContent(n, <unsigned char *> "content")
# xmlDocSetRootElement(doc, n)

xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1)
xmlFrag = <char* > xmlbuff
print "%d bytes in string" % len(xmlFrag)
print "[%s]" % xmlFrag

vic
Jul 18 '05 #1
0 1026

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Rene Olsthoorn | last post by:
Dear readers, py2exe has a problem including libxml2. Not at building time, but at runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has the problem? (and can you drop me...
10
by: Kyler Laird | last post by:
I need to submit C/C++ code for a class. (It's not a programming class. The choice of language is inertial. I think that it mostly serves to distract students from the course subject.) I'm...
15
by: John Salerno | last post by:
After my last post, I thought of another question as a result of the following: ------------------------------ Mike Meyer wrote: > John Salerno <johnjsal@NOSPAMgmail.com> writes: > > >>So...
27
by: Julien Fiore | last post by:
Do you wand to install Pyrex on Windows ? Here is a step-by-step guide explaining: A) how to install Pyrex on Windows XP. B) how to compile a Pyrex module. Julien Fiore, U. of Geneva
11
by: Jim Lewis | last post by:
Has anyone found a good link on exactly how to speed up code using pyrex? I found various info but the focus is usually not on code speedup.
1
by: cesar.ortiz | last post by:
Hi all, I have created an example using libxml2 based in the code that appears in http://xmlsoft.org/python.html. My example processes an enough amount of html files to see that the memory...
1
by: Andrew Marlow | last post by:
guys, I have been using libxml2 with python with no problems for just over a week but now I come to see if my script will work in someone else's environment and the libxml2 import fails. I am...
6
by: saumya.agarwal | last post by:
Hi, I am using libxml2 for xml parsing. When the client application sends data to libxml2 in UTF-8 format, it works fine. But, I have a scenarion in which the client application sends data to...
2
by: jianbing.chen | last post by:
Hi, I have this weird situation where on the same machine(solaris 8, python 2.5), one user can do this with no problem: <module 'libxml2' from '/usr/local/lib/python2.5/site-packages/...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.