473,513 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please Help with replaceChild

How can I do the following in python:
compare the text in the element tags <li> with the elements
tags in filling and if they match replace the text within the elements
tags <li> with the text in the matching element tag of fillin.
For example Since the text Monday in form matches the Element tag
<Monday> in fillin put maandag in the element tag <li> of Monday.
Kind of a Pseudo Code
Fo information:
get element tags for li
get text for li
Fi information:
get childtags for dutchdays
if(text for li=child tags for dutchdays):
replace child tags for dutchdays text with text for li
Some pieces of code that I tried out but cannot put together to get the
results.

import xml.dom.minidom
from xml.dom.minidom import parseString
import xml.xpath

form="""
<html>
<head> <title> My Sample Web Page </title> </head>
<body bgcolor="white">
<p>
What are the weekdays?
<ol>
<li>Monday</li>
</ol>
</p>
</body>
</html>
"""

fillin="""
<dutchdays>
<Monday>maandag</Monday>
<Tuesday>dinsdag</Tuesday>
<Wednesday>woensdag</Wednesday>
<Thursday>donderdag</Thursday>
<Friday>vrijdag</Friday>
<Saturday>zaterdag</Saturday>
<Sunday>zondag</Sunday>
</dutchdays>
"""

Fo = xml.dom.minidom.parseString(form)
Fi = xml.dom.minidom.parseString(fillin)

form_doc = parseString(form)
fill_doc = parseString(fillin)

for li in xml.xpath.Evaluate("//li", form_doc):
li.normalize()
day_text = li.childNodes[0]
day_str = day_text.nodeValue
for Monday in xml.xpath.Evaluate("//Monday", fill_doc):
Monday.normalize()
mon_text = Monday.childNodes[0]
mon_str = mon_text.nodeValue
#I want the to put the replace here put I have tried everything and
errors keep coming up

I am totally lost and do not know what to do could someone explain to
me what to do because I have looked at the python.org material and have
accomplished nothing.

Thanks

Oct 17 '05 #1
0 1422

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

Similar topics

2
16148
by: Joe Kelsey | last post by:
I want to create dynamic content and use replaceChild to switch out different subtrees. I start with a span placeholder: <span id="replaceMe"></span> Then I use document.getElementById...
4
2468
by: Lukasz Indyk | last post by:
hello;) i have a piece of html code, and want to replace every image on my page with this code. now i do it by replacing IMG node with SPAN node, and then setting innerHTML property of SPAN node...
2
5749
by: bissatch | last post by:
Hi, I am trying to use JavaScript to write a table column on a web page. The code is as follows: <html> <head> <script> function displaycount() {
0
1625
by: theFLY | last post by:
This has posted in the ASP sub-forum, to no avail I re-post here. Hello there, I have an XML file of structure that looks like this: <?xml version="1.0"?> <documents> <header...
1
1234
by: luthriaajay | last post by:
Has anyone used the 'importNode' and the 'replaceChild' methods of Interface Document and Node or adding 2 XML documents ? I need to add 2 XML documents in Java. DocumentOne -----------...
4
2392
by: sdustinh | last post by:
First, here is the code. function swapMP (theMPvalue) { if (theMPvalue !== "custom") { return; } var customMP = document.getElementById("part_mp"); var newCustomMP =...
6
2776
by: cantrell78 | last post by:
I can't for the life of me figure out how to execute javascript inside of div that was set using innerHTML or in my case using cloneNode and replaceChild (not my idea to do this, I'm just fixing...
3
1623
by: Michael | last post by:
Hey guys Im trying to build a plugin for a php script. Its going fine and dandy. Data is store in an XML file. Which has the following structure: <raiders> <raider> <name>Anarchie</name>...
5
13305
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
7160
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...
1
7099
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
7525
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
5086
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
4746
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
3233
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
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 ...
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.