Please, help me with following code snippet
' Load xml document
Dim xmlDoc As New XmlDocument()
xmlDoc.Load(http://localhost/VT/reports/VT_actual_owsPivotTable.xml)
' define namespacemanager
Dim xmlNs As New XmlNamespaceManager(xmlDoc.NameTable)
Dim nsUri As String = xmlDoc.DocumentElement.GetNamespaceOfPrefix("x")
xmlNs.AddNamespace("x", nsUri)
' create template node
Dim templateNode As XmlNode
Dim memberNode as XmlNode
Dim nameNode as XmlNode
Dim uNameNode as XmlNode
templateNode = xmlDoc.CreateNode(XmlNodeType.Element, "x:IncludedMember",
nsUri)
nameNode = xmlDoc.CreateNode(XmlNodeType.Element, "x:Name", nsUri)
templateNode.AppendChild(nameNode)
uNameNode = xmlDoc.CreateNode(XmlNodeType.Element, "x:UniqueName", nsUri)
templateNode.AppendChild(uNameNode)
' find insertion node
Dim pivotfieldNode as XmlNode
pivotfieldNode =
xmlDoc.SelectSingleNode("/xml/x:PivotTable/x:PivotField[x:SourceName='[WorkW
eek].[Day]']", xmlNs)
' create clone node
memberNode = templateNode.Clone
' update node value
nameNode = memberNode.SelectSingleNode("/x:IncludedMember/x:Name", xmlNs) '
<=== returns Nothing!!!
....
Strangely enough, xmlNs.LookupNamespace("x") return "" instead of the uri
"urn:schemas-microsoft-com:office:excel"
A partial content of the xml document :
<xml xmlns:x="urn:schemas-microsoft-com:office:excel">
<x:PivotTable>
....
<x:PivotField>
<x:Name>Day</x:Name>
<x:SourceName>[WorkWeek].[Day]</x:SourceName>
<x:Orientation>Column</x:Orientation>
<x:Position>3</x:Position>
<x:CompareOrderedMembersBy>Name</x:CompareOrderedMembersBy>
<x:IncludedMember>
<x:Name>4</x:Name>
<x:UniqueName>[WorkWeek].[All WorkWeek].[2003].[Week 27].[4]</x:UniqueName>
</x:IncludedMember>
</x:PivotField>
....
</x:PivotTable>
</xml>