Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-14-2017, 12:53 AM
slaycock slaycock is offline Problem adding a namespace for customxml Windows 7 64bit Problem adding a namespace for customxml Office 2013
Expert
Problem adding a namespace for customxml
 
Join Date: Sep 2013
Posts: 255
slaycock is on a distinguished road
Default

Quote:
it is if your XML uses a names space then to access the nodes you must reference the namespace prefix. If you don't name it something then Word automatically uses the default namespace prefix ns0.
This is the bit that is confusing because it is not made clear that Word automatically adds a prefix if you define a default namespace. My understanding of XML (whilst limited) suggests that if you define a default namespace (which is what I'm doing), then prefixes are not required.

https://www.w3schools.com/xml/xml_namespaces.asp

Look under default namespaces.

Quote:
Default Namespaces
Defining a default namespace for an element saves us from using prefixes in all the child elements. It has the following syntax:

xmlns="namespaceURI"
This XML carries HTML table information:

<table xmlns="http://www.w3.org/TR/html4/">
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>


</table>
This XML carries information about a piece of furniture:

<table xmlns="https://www.w3schools.com/furniture">
<name>African Coffee Table</name>
<width>80</width>
<length>120</length>
</table>
Once I had the insight that Word was not behaving in line with the reading I'd been doing progress was rapid.

However, even then Word did not appear to play fair. This is the XML output from the test suite above.

Code:
<?xml version="1.0"?>

<arcRoot xmlns="MyUserNS">
	<arcProp ns0:ID="myProp1" xmlns:ns0="MyUserNS">
		<Checked>False</Checked>
		<Enabled>True</Enabled>
		<Value>True</Value>
	</arcProp>
	<arcProp ns0:ID="myProp6" xmlns:ns0="MyUserNS">
		<Visibility>True</Visibility>
		<Checked>False</Checked>
		<Enabled>True</Enabled>
	</arcProp>
	<arcProp ns0:ID="myProp7" xmlns:ns0="MyUserNS">
		<Value>True</Value>
		<Visibility>True</Visibility>
		<Checked>False</Checked>
		<Enabled>True</Enabled>
	</arcProp>
	<arcProp ns0:ID="myProp8" xmlns:ns0="MyUserNS">
		<Visibility>True</Visibility>
		<Checked>False</Checked>
		<Enabled>True</Enabled>
		<Value>True</Value>
	</arcProp>
-	<arcProp ns0:ID="myProp9" xmlns:ns0="MyUserNS">
		<Visibility>True</Visibility>
		<Checked>False</Checked>
		<Enabled>True</Enabled>
		<Value>True</Value>
	</arcProp>
</arcRoot>
As you can see the elements of each property do not use a prefix. However in my code it *WAS* necessary to add a prefix in the VBA code to access the elements (this is in line with the prefix examples fiven earlier in the W3 reference).

I'm happy to accept that my understanding of CustomXMLParts and XML is insufficient which is why I think I'm seeing discontinuities but the evidence to date suggests not.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem batch adding autotext using Greg Maxey's Building Blocks Add-In Genuine Gin Word VBA 5 12-16-2015 10:20 AM
Problem Sending Command to the Program - Office or Windows Problem ?? JosieNurse Office 0 04-21-2015 11:49 AM
Problem adding a namespace for customxml Problem with Resolution when adding a picture in 2010 Zimm PowerPoint 1 11-13-2013 12:15 PM
Problem adding a namespace for customxml Problem with adding a footnote in Word Swarles_Barkley Word 1 11-12-2013 11:42 PM
Problem adding a namespace for customxml Adding Image into a excel cell and adding a hyperlink to the image saravananiyyanar Excel 3 05-04-2011 08:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:30 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft