Group:  General ยป microsoft.public.office.xml
Thread: How to Associate Custom Data with XMLNode object?

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

How to Associate Custom Data with XMLNode object?
"Ignoramus" <oleg.krupnov[ at ]gmail.com> 12.09.2006 16:23:25
What is the best way of associating application-defined data with
XMLNode objects?

Word's XMLNode object doesn't unfortunately have the Tag property (like
many other Office objects), where I could store some data.

Also I can't create a Dictionary, because XMLNode objects cannot be
used as dictionary keys - they are obviously (like Range objects)
volatile views of some opaque internal objects. In other words, (node1
is node2) can be false even if node1 and node2 are actually the same
node in the source XML.

Another option is to use what I call "paths", i.e. an array of integers
where each element represents the index in the array of sibling nodes
of the current parent node, recursively. This method would be great but
it goes broke when the XMLAfterInsert event fires in result of the
"apply tag" command (the event is not fired for the child nodes wrapped
by the new node). In that case the paths of the child nodes change and
no longer can be resolved, because the event is fired AFTER the XML has
already been changed.

The last brute force option I'm considering is to introduce a
persistent attribute for each XML node, containing some kind of unique
identifier and to reference custom data by that id. The problem is
however that this service attribute can be occasionally changed/removed
by the user and the approach will fail. Also, I'd not like to introduce
extra data not desired by the user.

Am I missing the right way of doing it? Please advice.

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net