Re: Editting an XML file



David wrote:

I know there are many parts of XML that do not work in CF, for example xpath and xquery. The selectsinglenode is not directly supported, but I have found an overriden xmldocument that has a selectsinglenode.

MS does not support XQuery at all in the .NET framework. XPath is supported in both the normal .NET framework and the compact framework.

One of the probs I have is that of navigating rows (nodes with the same name...). The sample xml will be too big here, so I have a layout sample...


Part
PartId (nodes under here)
PartOperations
PartImages
PartImage
PartRegions
PartRegions
GridRef
Features
PartFeature
(various nodes under PartFeature)
PartRegions
GridRef
Features
PartFeature

Also, under part feature are other nested nodes. Because of this structure, I cannot really just select for example...

/Part/PartId/PartImages/PartImage/PartRegions/PartRegions/Features/PartFeature/<bit I want to change>

in order to change a node. I somehow need to navigate through the nodes.

I guess (and I will give it a try) that I can go to

/Part/PartId/PartImages/PartImage/PartRegions/

then loop through all the (second level) PartRegions, replacing at will. Does that sound like a plan?

Your structure is not clear, PartId, PartOperations, PartImages look like siblings yet you use /Part/PartId/PartImages as if PartImages is a child of PartId.
It is also not clear what exactly you want to change.
As for navigation, navigation in the DOM model can be done in various ways, each node has a ChildNodes property, a FirstChild and LastChild property, has NextSibling and PreviousSibling, and with DOM in the .NET framework you have SelectNodes and SelectSingleNode not only on the document node but on other nodes as well so you can use relative XPath expression and those methods to access anything XPath allows you to select. That way it is certainly possible to access certain nodes first and then use further SelectSingleNode or SelectNodes on those nodes to select children elements (*) or descendant elements (.//*).



--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
.


Loading