Re: Editting an XML file



Hi,

My mistake, PartID should not have been in my select statement. Sorry for
the confusion.

I am using .net CF1 and xpath is not in the framework. I don't think it is
in CF2 either.

Aside from that, your example led me onto a solution.

Due to the limitations of the XML stuff in compact framework, I am having to
loop through stuff (quite resource hungry I'm sure, but until I have more
experience, I can live with that.)

I have made my xdoc visible to the whole app, I open a doc inside my
form_load, looping through it to get at my data, then displaying it.

When ready, I click a save button. This gets the xdoc that is already open
and basically, all I do is to swap around read/write part of the statements
(I didn't know about this, your example told me...). I didn't know how to
save it either, again, your example showed me this.

I am happy now. Just got to do more rigourus testing now.

As an example, can you show me how to navigate to each PartFeature and to
get values out of say, 'FeatureID' under PartFeature, within the limitations
of the compact framework?

Thanks.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available


"Martin Honnen" <mahotrash@xxxxxxxx> wrote in message
news:%2300fl8RWIHA.1208@xxxxxxxxxxxxxxxxxxxxxxx
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