473,587 Members | 2,579 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>dinsda g</Tuesday>
<Wednesday>woen sdag</Wednesday>
<Thursday>donde rdag</Thursday>
<Friday>vrijdag </Friday>
<Saturday>zater dag</Saturday>
<Sunday>zonda g</Sunday>
</dutchdays>
"""

Fo = xml.dom.minidom .parseString(fo rm)
Fi = xml.dom.minidom .parseString(fi llin)

form_doc = parseString(for m)
fill_doc = parseString(fil lin)

for li in xml.xpath.Evalu ate("//li", form_doc):
li.normalize()
day_text = li.childNodes[0]
day_str = day_text.nodeVa lue
for Monday in xml.xpath.Evalu ate("//Monday", fill_doc):
Monday.normaliz e()
mon_text = Monday.childNod es[0]
mon_str = mon_text.nodeVa lue
#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 1429

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

Similar topics

2
16154
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 ("replaceMe") to find the element to replace. I create a subtree using standard DOM: var table = document.createElement ("table"); table.insertRow ();
4
2481
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 with my html code: var nodeToReplaceWith = document.createElement("<SPAN>"); nodeToReplaceWith.innerHTML = HTMLCodeToReplaceWith;...
2
5758
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
1633
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 id="1"> <title></title>
1
1239
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 ----------- <?xml version="1.0" encoding="UTF-8"?>
4
2408
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 = document.createElement("input");
6
2782
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 it). I have tried it with and without the defer attribute. It will work fine in firefox, but not IE. <script type="text/javascript"> function...
3
1625
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> <ready>?</ready>
5
13336
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 http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the...
0
7843
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
8206
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8340
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
8220
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...
1
5713
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5392
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
3840
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
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1452
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.