Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XML, can add a child node but can't delete one.
Message
De
30/03/2001 02:29:50
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
29/03/2001 18:04:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Divers
Thread ID:
00490116
Message ID:
00490230
Vues:
9
>Using Microsoft XMLDOM for IE 5.0.
>loxml = CreateObject([MicroSoft.XMLDOM])
>
>Okay, so appendchild() works like a dream. I can add new child nodes no problem but I just can't figure out RemoveChild().
>
>I load the XML document and attempt to delete the first child node but it gives an error message about type mismatch. I then do a selectnodes and get the node and its children nodes that I want to remove. I try loxml.item(0).removechild() and quite a few other combinations but I get errors each time.
>
>Ideas and/or help?

Fred,
In your code node object for removeChild() is missing. Here is an extract from an MS supplied sample (tree sample I think) :
function del(sText)
{
intX = Spliter(sText,1);
for(i=0;i<(xmldso.getElementsByTagName("TaskPK").length);i++)
	{
	if(xmldso.getElementsByTagName("TaskPK")(i).text==intX)
xmldso.getElementsByTagName("TaskPK")(i).parentNode.parentNode.removeChild(xmldso.getElementsByTagName("TaskPK")(i).parentNode);
	}
}

* XML looks like

< ?xml version="1.0"? >
< Category xmlns:dt="urn:schemas-microsoft-com:datatypes" xmlns:rs="urn:schemas-microsoft-com:rowset" lock="false" >
   < row >
      < dbX_Action >None< /dbX_Action >
      < dbX_Relation >ParentCategoryFK=CategoryPK< /dbX_Relation >
      < CategoryPK dt:dt="int" rs:isautoincrement="true" rs:keycolumn="true" >1< /CategoryPK >
      < ParentCategoryFK dt:dt="int" >0< /ParentCategoryFK >
      < ProjectFK dt:dt="int" >1< /ProjectFK >
      < CategoryName dt:dt="string" >Database Design< /CategoryName >
      < Category lock="false"/ >
      < Task lock="false" >
         < row >
            < dbX_Action >None< /dbX_Action >
            < dbX_Relation >CategoryFK=CategoryPK< /dbX_Relation >
            < TaskPK dt:dt="int" rs:isautoincrement="true" rs:keycolumn="true" >1< /TaskPK >
            < ProjectFK dt:dt="int" >1< /ProjectFK >
            < CategoryFK dt:dt="int" >1< /CategoryFK >
            < Name dt:dt="string" >DB Design 1< /Name >
            < Duration dt:dt="int" >5< /Duration >
            < Start dt:dt="string" >6/1/2000< /Start >
            < Finish dt:dt="string" >6/5/2000< /Finish >
            < Timesheet lock="false"/ >
         < /row >
         < row >
...


* HTML portion calling del()
< !--Task-- >
< TABLE width=392 datasrc="#xmldso" datafld="Task" border=0 cellpadding=0 cellspacing=0 >
	< TR >
	< TD colspan=4 >
		< DIV ID='tblTree2' STYLE="DISPLAY: none" >
		< TABLE datasrc="#xmldso" datafld="row" border=0 cellpadding=0 cellspacing=0 >
		< TR >
		< TD width=160 >
		< INPUT datafld=Name style="color:red;BACKGROUND-COLOR: lightyellow; BORDER-BOTTOM-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-RIGHT-STYLE: none; BORDER-TOP-STYLE: none" >
		< span class=cmd onclick="del(this.innerText)" >del < span STYLE="DISPLAY: none" datafld=TaskPK  >< /span >< /span >
		< /TD >
'del' lines have say :
del 3
in html with TaskPk 3 diplay:none and spliter splits the innerText to return 3.

Hope helps.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform