all groups > dotnet xml > may 2005 >
You're in the

dotnet xml

group:

Change NameSpace Value on Selected Node


Re: Change NameSpace Value on Selected Node Martin Honnen
5/10/2005 12:00:00 AM
dotnet xml:

[quoted text, click to view]

XPathDocument is always read-only, whether you want to change a
namespace or something else, it is not possible with an XPathDocument.
Even with an XmlDocument it is not possible to simply change a namespace
URI associated with an element or attribute node as the namespace is
determined during creation of the node thus you have to create new
elements or attributes in the proper namespace.
An XSLT stylesheet is often helpful to transform an XML document to
another XML format changing stuff like namespaces as needed.
If you show us some example input and desired output then we can show
you how to transform that with XSLT.


--

Martin Honnen --- MVP XML
Change NameSpace Value on Selected Node Rick
5/10/2005 9:10:24 AM
I have an XML document that is generated from Infopath, I need to change
the value of a namespace that is defined in a node in the form:
<xsf:xDocumentClass "xmlns:my=valuehere">.
when i navigate to the namespace value it is read only and cannot be
changed. Can anyone tell me how to change this value?

My Code:

Dim sSingleNode As XmlNode = objDoc.SelectSingleNode("//xsf:Node",
NamespaceManager)
Dim nav As XPathNavigator
Dim docNav As XPathDocument
docNav = New XPathDocument(sFile)
nav = docNav.CreateNavigator
nav.MoveToRoot()
nav.MoveToFirstChild()
nav.MoveToNext()
nav.MoveToFirstNamespace()
Do
If nav.Name.ToUpper = "MY" Then
nav.Value = Value 'Change value here
End If
Loop While nav.MoveToNextNamespace

Thanks in Advance,
Rick

Re: Change NameSpace Value on Selected Node Rick
5/10/2005 12:12:02 PM
I am fairly new to XML, but what I am doing is this, when creating an
InfoPath form a manifest.xsf file is created the first node in the file is
something like this:

<xsf:xDocumentClass trustSetting="automatic" dataFormSolution="yes"
solutionVersion="1.0.0.3" productVersion="11.0.6357"
solutionFormatVersion="1.100.0.0" publishUrl="E:\InfoPath
Documents\CurrentSPInfo\manifest.xsf"
name="urn:schemas-microsoft-com:office:infopath:CurrentSPInfo:-dataFormSolution"
xmlns:xsf="http://schemas.microsoft.com/office/infopath/2003/solutionDefinition"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xdUtil="http://schemas.microsoft.com/office/infopath/2003/xslt/Util"
xmlns:xdXDocument="http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument"
xmlns:xdMath="http://schemas.microsoft.com/office/infopath/2003/xslt/Math"
xmlns:xdDate="http://schemas.microsoft.com/office/infopath/2003/xslt/Date"
xmlns:tns="http://schemas.ConvergenceComm.com/SPInfo/IPLists"
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-05-10T11:05:30"
xmlns:ns1="http://schemas.ConvergenceComm.com/SPInfo/IPLists/Query"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns2="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

I need to open this first node find the "my" namespace(highlighted in Red)
and change the value.

Thanks.


[quoted text, click to view]

AddThis Social Bookmark Button