vba - Can't remove default xml namespace attribute? -
why can't remove namespace attributes?
<?xml version="1.0" encoding="utf-8"?> <trainingcenterdatabase xsi:schemalocation="http://www.garmin.com/xmlschemas/trainingcenterdatabase/v2 http://www.garmin.com/xmlschemas/trainingcenterdatabasev2.xsd" xmlns:ns5="http://www.garmin.com/xmlschemas/activitygoals/v1" xmlns:ns4="http://www.garmin.com/xmlschemas/profileextension/v1" xmlns:ns3="http://www.garmin.com/xmlschemas/activityextension/v2" xmlns:ns2="http://www.garmin.com/xmlschemas/userprofile/v2" xmlns="http://www.garmin.com/xmlschemas/trainingcenterdatabase/v2" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" > sub insstyles(xmlfil string) dim xmldoc msxml2.domdocument60 dim stylepi msxml2.ixmldomprocessinginstruction dim xnodelist msxml2.ixmldomnodelist dim xnode msxml2.ixmldomnode dim xatt msxml2.ixmldomattribute dim tabort1, tabort2 string set xmldoc = new domdocument60 if not xmldoc.load(xmlfil) err.raise xmldoc.parseerror.errorcode, , xmldoc.parseerror.reason end if set xnodelist = xmldoc.childnodes each xnode in xnodelist if xnode.basename = "trainingcenterdatabase" '***** each xatt in xnode.attributes tabort1 = cstr(xatt.name) tabort2 = cstr(xatt.namespaceuri) ' xnode.attributes.removenameditem tabort1 xnode.attributes.removequalifieditem tabort1, tabort2 next xatt '***** end if if xnode.basename = "xml-stylesheet" xnode.parentnode.removechild xnode end if next xnode set stylepi = xmldoc.createprocessinginstruction("xml-stylesheet", _ "type=""text/xsl"" href=""wahoo_tcx.xsl""") xmldoc.insertbefore stylepi, xmldoc.childnodes.item(1) xmldoc.save xmlfil set xmldoc = nothing end sub` name , namespaceuri produce this:
xsi:schemalocation http://www.w3.org/2001/xmlschema-instance xmlns:ns5 http://www.w3.org/2000/xmlns/ xmlns:ns4 http://www.w3.org/2000/xmlns/ xmlns:ns3 http://www.w3.org/2000/xmlns/ xmlns:ns2 http://www.w3.org/2000/xmlns/ xmlns http://www.w3.org/2000/xmlns/ xmlns:xsi http://www.w3.org/2000/xmlns/ but won't remove anything, ‘basename’ , ‘namespaceuri’ remove prefix not ‘xmlns’ default ‘namespace’. name , ‘removenameditem’ same. not allowed remove default ‘namespace’? if have ‘xmlns’ prefix removed. , why ‘namespaceuri’ different what’s in xml-file?
Comments
Post a Comment