473,387 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Change NameSpace Value on Selected Node

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
Nov 12 '05 #1
2 6782


Rick wrote:
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


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
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
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.
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:OD****************@TK2MSFTNGP14.phx.gbl...


Rick wrote:
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


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
http://JavaScript.FAQTs.com/

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: wooks | last post by:
I want to apply 2 changes to the following xml <ROOTSTUB app="appname"/> 1. change the app attribute to an element. 2. put the ROOTSTUB element into a namespace that is passed as a global...
5
by: Alexander Gnauck | last post by:
Hello, i have problems with the Namespaces and the .Net XML Parser My XML looks like this: <query xmlns="jabber:iq:roster"> <item jid="srlee@localhost" name="srlee"...
6
by: David B. Bitton | last post by:
I am having a problem deserializing XML when the root node is missing a namespace declaration. My Type has an XmlTypeAttribute with a namespace defined. If I attempt to deserialize the XML, I get...
5
by: SenthilSS | last post by:
My application produces XML Data files which have XML namespace qualified XML elements (nodes), but the namespace itself is not declared in the data file. My task is to read these data files in a...
0
by: beanweed | last post by:
BACKGROUND ---------- I have an ASP.NET application having two panels. In one panel, an XML document, transformed using xsl, is displayed. In the other panel are some controls that allow a user...
0
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku...
4
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku...
3
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml...
4
by: RP | last post by:
I have a TreeView control. When a user clicks on a node, it must change color. I did: TreeView1.SelectedNode.ForeColor = colors.Blue; However, it must change the other nodes color to black,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.