473,473 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Inserting an element into existing xml file

Hi,

I'm new to Python. we are using python2.4.

I wanted to insert an element into an existing xml file. Can anyone
help me with this?
I've seen lxml and elementTree in python2.5 has some API's to insert
into existing xml file.
We cant use python 2.5 due to some limitations. So how can we do it in
2.4?

Thanks in Advance,
Anand

Sep 25 '07 #1
4 2573
Anand wrote:
I'm new to Python. we are using python2.4.

I wanted to insert an element into an existing xml file. Can anyone
help me with this?
I've seen lxml and elementTree in python2.5 has some API's to insert
into existing xml file.
We cant use python 2.5 due to some limitations. So how can we do it in
2.4?
Install lxml and read the tutorial. It should be easy to grasp, as the API is
very simple.

http://codespeak.net/lxml/tutorial.html
http://codespeak.net/lxml/tutorial.h...ents-are-lists

It's compatible to ElementTree, which you can also install on Python 2.4 (it's
what later became part of Python 2.5).

Stefan
Sep 25 '07 #2
On Sep 25, 3:20 pm, Stefan Behnel <stefan.behnel-n05...@web.dewrote:
Anand wrote:
I'm new to Python. we are using python2.4.
I wanted to insert an element into an existing xml file. Can anyone
help me with this?
I've seen lxml and elementTree in python2.5 has some API's to insert
into existing xml file.
We cant use python 2.5 due to some limitations. So how can we do it in
2.4?

Install lxml and read the tutorial. It should be easy to grasp, as the API is
very simple.

http://codespeak.net/lxml/tutorial.h...ents-are-lists

It's compatible to ElementTree, which you can also install on Python 2.4 (it's
what later became part of Python 2.5).

Stefan

Hi Stefan,

First of all thanks for your reply.

I'm Afraid to say, I can't use lxml or elementTree as it requires many
legal approvals and there is high chances of not getting it through.
So Do you have any other method / idea just by using plain 2.4 to
accomplish the task

Cheers,
Anand

Sep 25 '07 #3
On Tue, 25 Sep 2007 03:30:05 -0700, Anand wrote:
I'm Afraid to say, I can't use lxml or elementTree as it requires many
legal approvals and there is high chances of not getting it through.
In what environment is it hard to get something BSD licensed through!?

Ciao,
Marc 'BlackJack' Rintsch
Sep 25 '07 #4
Anand wrote:
I'm Afraid to say, I can't use lxml or elementTree as it requires many
legal approvals and there is high chances of not getting it through.
So Do you have any other method / idea just by using plain 2.4 to
accomplish the task
Are you allowed to use code samples you found on the net?

http://svn.effbot.org/public/elementtree/

(if not, are you even allowed to ask for help? ;-)

ElementTree (aka xml.etree) is pure Python, and you only need the
ElementTree.py module to do what you want, so I guess you could
always pretend you wrote it yourself...

</F>

Sep 26 '07 #5

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

Similar topics

2
by: Wim Roffal | last post by:
I want to insert an option into a select. I know you can do something like: - Myselect.options = new Option('Hello 3'); but that doesn't do what I want because it overwrites an existing option....
1
by: Stanimir Stamenkov | last post by:
I've wondered if it is right thing to do: element.parentNode.insertBefore(element, beforeElement); where 'beforeElement' is one of the 'element.parentNode.childNodes'? First, I've used: ...
1
by: Stephen | last post by:
I have the following for a datagrid that inserts a row into an xml file. It works great, but inserts the data to a new top-level node. I don't know how to specifiy an existing node for the...
2
by: a | last post by:
NEW Post Here's my best guess at how to insert this dataset.... the code runs, but no new records are added to the sql table. I've read and split a delimited text file into a dataset. It...
2
by: C# to XML | last post by:
Hi friends, I am new to csharp and XML : fp=File.OpenText(server.mappath(".\\upload\\")+"test.txt"); string info=fp.readtoend(); string arinfo =new string; char splitter = {'|','^'}; ...
2
by: gruvin | last post by:
Hi. I need to insert an image element into text in an iframe in design mode. That part I can do: var sel = oEditor.eFrameDoc.selection; var range = sel.createRange(); range.pasteHTML('<img...
12
by: desktop | last post by:
Why does insert only work when specifying an iterator plus the object to be inserted: std::vector<intt; std::vector<int>::iterator it; it = t.begin(); t.insert(it,33); If I use push_back...
1
by: madhuxml82 | last post by:
Dear Forum Members, I have generated an XML Schema and a Table of XMLType referencing the XML Schema. Now When I am Inserting the Data into the Table. I am getting the Error 0RA-30937: Error is...
1
by: ofuuzo1 | last post by:
Hi, Is there anyway I can append a new element to an existing xml without first loading the existing file into a variable, adding the new element into the variable and saving it by overwriting the...
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
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 ...
1
muto222
php
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.