This is what I've tried:
My XML file looks like this
......
<Collection name="DbTestCollection1" TopLeftX="-86.4037416919"
TopLeftY="20.63144694" BottomRightX="-86.3945403259"
BottomRightY="20.626370603" DefaultFloor="1">
<Layers PATH="C:\Program Files\Maps">
<Layer IMAGE="DB_map.tif" BASE="true" />
<Layer IMAGE="FloorPlan2.tif" BASE="false" BUILDING="1" FLOOR="1" />
</Layers>
<Buildings>
<Building number="1" CN="Building_1" />
</Buildings>
<Floors>
<Floor number="1" CN="Floor_1" BuildingNumber="1" />
</Floors>
<Columns>
<Column number="0" CN="Column A" BuildingNumber="1" />
</Columns>
</Collection>
......
I look for my local node in the file first then I create a new one from the
databse to replace it:
// Look for the node name in the collections file
XmlNode localNode = FindNode(_name,xmlDoc);
// now I create the new node
// Collection name
collectionNode = _xmlDoc.CreateNode(XmlNodeType.Element,"Collection","");
// Collection Name
XmlAttribute attr = _xmlDoc.CreateAttribute("name");
attr.Value = map.Name;
collectionNode.Attributes.Append(attr);
.....
....
....
// Then I call replace node
localNode.ParentNode.ReplaceChild(collectionNode,localNode);
this seems to only replace the
<Collection name=........></Collection>
tag and non of its children.
Thanks
Ed;;
[quoted text, click to view] "Martin Honnen" wrote:
>
>
> Ed A wrote:
>
> > Is there a way to replace a node and it's children? I tried using the
> > ReplaceChild method but that seems to only replace the first child only!!
>
> node.ParentNode.ReplaceChild(newNode, node)
> will replace node with newNode.
>
> If you still have problems then provide more details on what you have tried.
>
> --
>
> Martin Honnen --- MVP XML
>
http://JavaScript.FAQTs.com/