vb.net xml namespace prefixes
Posted on 2011-02-11
This, to me, seems like a related question...along the lines of xml namespaces and their respective prefixes. Let me see if I can explain matters clear enough for you guys/gals to be able to help me out since this has been plaguing me for a long long time.
I have an xml document w/ one namespace whose shortcut abbreviation is 'ns'. Now this xml document is really just the skeleton or template of the xml layout. Our aim, most of the time, is to add in the values, for example <ns:firstname></ns:firstname> will end up being <ns:firstname>JOHN</ns:firstname>.
First off, since there's only one namespace being used...is it "wrong" to prefix every element in the xml document with the prefix 'ns:'?? Is there any advantage to this? I'm sure if I ask my boss he will say that in the future there could be another namespace being used...but after a few years, this hasn't changed!
The real problem though is when I have to add in another xml element. So let's say I have to add in a shoe size element, <ns:shoeSize></ns:showSize>. Yes it has to be added in, it can't be just filled in with a value because it's presence is optional. For the life of me I can't figure out how to make the vb.net code add in the element WITH the 'ns:' prefix.