By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,818 Members | 1,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,818 IT Pros & Developers. It's quick & easy.

Replacing an XML element?

P: n/a
I've been trying to figure out how to do something that seems
relatively simple, but it's just not coming together for me. I'm
hoping someone will deign to give me a little insight here.

The problem: We have XML documents that use a custom table format that
was designed primarily for typesetting documents. It's a column-first
oriented scheme, and now we need a way to convert these table elements
to HTML style row-first tables.

I would like to be able to do something like this:

doc = xml.dom.minidom.parse(input)
for table in doc.getElementsByTagName('COLTABLE'):
newtable = coltable_to_rowtable(table)
## this is what I can't figure out
doc.replace(table, newtable)
output.write(doc.toxml('utf-8'))

I'm pretty sure I'm missing something obvious, but haven't been able
to find any examples.

Someone please whack me with a cluestick,

Nick

--
#include<stdio.h> /* sigmask (sig.c) 20041028 PUBLIC DOMAIN */
int main(c,v)char *v;{return !c?putchar(* /* cc -o sig sig.c */
v-1)&&main(0,v+1):main(0,"Ojdl!Wbshjti!=ojdlAwbshjt i/psh?\v\1");}
Sep 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Nick Vargish <na*******@bandersnatch.org> wrote in
news:87************@localhost.localdomain:
I've been trying to figure out how to do something that seems
relatively simple, but it's just not coming together for me. I'm
hoping someone will deign to give me a little insight here.

The problem: We have XML documents that use a custom table format
that was designed primarily for typesetting documents. It's a
column-first oriented scheme, and now we need a way to convert
these table elements to HTML style row-first tables.

I would like to be able to do something like this:

doc = xml.dom.minidom.parse(input)
for table in doc.getElementsByTagName('COLTABLE'):
newtable = coltable_to_rowtable(table)
## this is what I can't figure out
doc.replace(table, newtable)
output.write(doc.toxml('utf-8'))

I'm pretty sure I'm missing something obvious, but haven't been
able to find any examples.

Someone please whack me with a cluestick,

Nick


table.parentNode.replaceChild(newtable, table)
Sep 20 '05 #2

P: n/a
Max Erickson <ma*********@gmail.com> writes:
table.parentNode.replaceChild(newtable, table)


I knew it had to be something simple (but not as simple as I am,
apparently :^).

Thanks much, Max, you've saved the rest of my day.

Nick

--
#include<stdio.h> /* sigmask (sig.c) 20041028 PUBLIC DOMAIN */
int main(c,v)char *v;{return !c?putchar(* /* cc -o sig sig.c */
v-1)&&main(0,v+1):main(0,"Ojdl!Wbshjti!=ojdlAwbshjt i/psh?\v\1");}
Sep 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.