473,574 Members | 2,233 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help designing reading/writing a xml-fileformat

I'm writing a block-diagram editor, and could use some tips about
writing/reading
diagrams to/from an xml file format. The basic layout of my code :

class Diagram {
Blocks blocks[]
}

class Block {
int x, y
}

class Square(Block) {
int width, height
}

class Circle(Block) {
int radius
}

I'd like to be able to output something similar to this:

<diagram>
<square x='12' y='34' width='50' height='40'/>
<circle x='40' y='60' radius='20/>
</diagram>

One idea I had was to make Diagram and Block derive from
xml.dom.minidom .Element,
and then somehow catch when I set an attribute, so that setAttribute()
gets called with correct
arguments. Perhaps then I could just do a simple diagram.toprett yxml().

Anyone have a good idea on how to approach this problem ?
(I do not want to use the pickle module)

/Jacob Kroon

Dec 13 '05 #1
2 1337
[Jacob Kroon]
I'm writing a block-diagram editor, and could use some tips about
writing/reading
diagrams to/from an xml file format.
I highly recommend reading David Mertz excellent articles on the
conversion of objects to xml and vice-versa.

On the 'Pythonic' treatment of XML documents as objects, I + II
http://www-128.ibm.com/developerwork...rs1/index.html
http://www-128.ibm.com/developerwork...rs2/index.html

Revisiting xml_pickle and xml_objectify
http://www-128.ibm.com/developerwork...matters11.html
Anyone have a good idea on how to approach this problem ?
(I do not want to use the pickle module)


Why not the pickle module? XML-format pickles are a good solution to
your problem, IMHO.

--
alan kennedy
------------------------------------------------------
email alan: http://xhaus.com/contact/alan
Dec 13 '05 #2
Jacob Kroon wrote:
I'm writing a block-diagram editor, and could use some tips about
writing/reading
diagrams to/from an xml file format. The basic layout of my code :

class Diagram {
Blocks blocks[]
}

class Block {
int x, y
}

class Square(Block) {
int width, height
}

class Circle(Block) {
int radius
}

I'd like to be able to output something similar to this:

<diagram>
<square x='12' y='34' width='50' height='40'/>
<circle x='40' y='60' radius='20/>
</diagram>
[SNIP]
Anyone have a good idea on how to approach this problem ?
(I do not want to use the pickle module)


How about an XML pickle? PyXML has such a module. WDDX, also in
PyXML, is another option.

--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://fourthought.com
http://copia.ogbuji.net http://4Suite.org
Articles: http://uche.ogbuji.net/tech/publications/

Dec 13 '05 #3

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

Similar topics

6
301
by: Jake | last post by:
Hello, We have some code (see below) that has been working intermittently and I was wondering if someone had a better approach or an idea on why we get these errors. This part of code basically gets a file and uploads it from a cable or DSL connection to our t1 line to a server. The file size ranges from 1.7 MB to 4MB and there can be...
1
3699
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am attach this script files and inq files. I cant understand this error. Please suggest me. You can talk with my yahoo id b_sahoo1@yahoo.com. Now i am...
2
6589
by: arman | last post by:
Hi, I am newbie in php and i am having some probs. This is a cool forum and i ask for your help. so plz help me if u can. Here is my prob -- I am using domxml to read and write data from xml files . the reading and writing part works perfectly but i have problem using xslt. when i use this function ' domxml_xslt_stylesheet_file ' is...
0
797
by: jmdeschamps | last post by:
I have to work with XML data containing accented characters (ISO-8859-1 encoding) Using ElementTree, the only way i found to get the text attribute of a node was to encode it individually, if you want. It doubles the amount of time to process :-( i surely doing this wrong... What is the good way to do it? I didn't see an obvious way to do it...
2
2028
by: -D- | last post by:
I'm taking my first stab at using xml, so please bear with my novice questions and understanding of xml. I'm trying to create an xml file that holds all my website navigation. If I understand correctly, I can use xslt to create different menus from the xml file. What I'm trying to accomplish is to create a top menu bar, left navigation...
2
1215
by: Aryan | last post by:
Hi, I have problem related to Caching of data. I am reading large xml file and putting this xml in dataset, since this dataset will contain many datatable's inside. And each datatable might be big in data. Each user will contain its seperate xml file, so when I create xml file for each user, I am putting this xml DataSet in Cache object, but...
1
1379
by: Candle | last post by:
I am having a problem with writing an XSL Transform. Please help. Note: I know this a long post but I wanted to provide as must detail as possible. Any help would be appreciated. (Just started writing my first transform yesterday and no one at my company knows this stuff.) Assume I have the following XML: <P C="P" O="1" > <E C="P_E1"...
1
1520
by: Candle | last post by:
I am having a problem with writing an XSL Transform. Please help. Note: I know this a long post but I wanted to provide as must detail as possible. Any help would be appreciated. (Just started writing my first transform yesterday and no one at my company knows this stuff.) Assume I have the following XML: <P C="P" O="1" > <E C="P_E1"...
0
5546
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
4
1846
by: ramyakrishnakumar | last post by:
Hi All, I am facing some problem with basic file operation... I have one xml file looks like <?xml version="1.0" encoding="UTF-8" standalone="no" ?> <x:recording> <udf3>Gélin</udf3> </x:recording>
0
7801
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7719
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8229
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8096
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5299
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3739
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3749
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.