473,399 Members | 4,192 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,399 software developers and data experts.

XPathNavigator

C
When I try this

//WebSRFTemplate/Data/Field[Name='SERVICEStaticRoute2IPnetwork1']/text()

I get back the values of ALL Fields in my XML below. I only want the value
(Test1) of the field name specified.

Am I doing something wrong here?
<WebSRFTemplate Version="1" Type="SERVICE">
<Data>
<Field Name="SERVICEStaticRoute2IPnetwork1">"Test1"</Field>
<Field Name="SERVICEStaticRoute3Subnetmask">"Test2"</Field>
<Field Name="SERVICEStaticRoute3IPnetwork1">"Test3"</Field>
<Field Name="SERVICEStaticRoute3">"Test4"</Field>
</Data>
</WebSRFTemplate>
Jun 14 '06 #1
3 1751
C
The only way I can get this to work to do the following...

XmlNode xmlNode =
myXmlDoc.SelectSingleNode("//WebSRFTemplate/Data/Field[@Name='SERVICEStaticRoute2IPnetwork1']");

If I use /text() at the end of this my xmlNode is null.

To check if my node has a value I have to use xmlNode.InnerText

Anyone know why I can't use XmlNode xmlNode =
myXmlDoc.SelectSingleNode("//WebSRFTemplate/Data/Field[@Name='SERVICEStaticRoute2IPnetwork1']/text()");
as opposed to above?
"C" wrote:
When I try this

//WebSRFTemplate/Data/Field[Name='SERVICEStaticRoute2IPnetwork1']/text()

I get back the values of ALL Fields in my XML below. I only want the value
(Test1) of the field name specified.

Am I doing something wrong here?
<WebSRFTemplate Version="1" Type="SERVICE">
<Data>
<Field Name="SERVICEStaticRoute2IPnetwork1">"Test1"</Field>
<Field Name="SERVICEStaticRoute3Subnetmask">"Test2"</Field>
<Field Name="SERVICEStaticRoute3IPnetwork1">"Test3"</Field>
<Field Name="SERVICEStaticRoute3">"Test4"</Field>
</Data>
</WebSRFTemplate>

Jun 14 '06 #2
Name is an attribute in your XML, so you need

//WebSRFTemplate/Data/Field[@Name='SERVICEStaticRoute2IPnetwork1']/text()

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com

C wrote:
The only way I can get this to work to do the following...

XmlNode xmlNode =
myXmlDoc.SelectSingleNode("//WebSRFTemplate/Data/Field[@Name='SERVICEStaticRoute2IPnetwork1']");

If I use /text() at the end of this my xmlNode is null.

To check if my node has a value I have to use xmlNode.InnerText

Anyone know why I can't use XmlNode xmlNode =
myXmlDoc.SelectSingleNode("//WebSRFTemplate/Data/Field[@Name='SERVICEStaticRoute2IPnetwork1']/text()");
as opposed to above?
"C" wrote:
When I try this

//WebSRFTemplate/Data/Field[Name='SERVICEStaticRoute2IPnetwork1']/text()

I get back the values of ALL Fields in my XML below. I only want the value
(Test1) of the field name specified.

Am I doing something wrong here?
<WebSRFTemplate Version="1" Type="SERVICE">
<Data>
<Field Name="SERVICEStaticRoute2IPnetwork1">"Test1"</Field>
<Field Name="SERVICEStaticRoute3Subnetmask">"Test2"</Field>
<Field Name="SERVICEStaticRoute3IPnetwork1">"Test3"</Field>
<Field Name="SERVICEStaticRoute3">"Test4"</Field>
</Data>
</WebSRFTemplate>

Jun 14 '06 #3
C
That's what I haev as per below code snippet

XmlNode xmlNode =
myXmlDoc.SelectSingleNode("//WebSRFTemplate/Data/Field[@Name='SERVICEStaticRoute2IPnetwork1']/text()");

Yet my node is null each time.

If I take off the text(), my node is not null and I use xmlNode.InnerText to
get the value.

I don't understand why xmlNode is null when I use text() ?

"Oleg Tkachenko [MVP]" wrote:
Name is an attribute in your XML, so you need

//WebSRFTemplate/Data/Field[@Name='SERVICEStaticRoute2IPnetwork1']/text()

--
Oleg Tkachenko [XML MVP, MCAD]
http://www.XmlLab.Net | http://www.XLinq.Net | http://blog.tkachenko.com

C wrote:
The only way I can get this to work to do the following...

XmlNode xmlNode =
myXmlDoc.SelectSingleNode("//WebSRFTemplate/Data/Field[@Name='SERVICEStaticRoute2IPnetwork1']");

If I use /text() at the end of this my xmlNode is null.

To check if my node has a value I have to use xmlNode.InnerText

Anyone know why I can't use XmlNode xmlNode =
myXmlDoc.SelectSingleNode("//WebSRFTemplate/Data/Field[@Name='SERVICEStaticRoute2IPnetwork1']/text()");
as opposed to above?
"C" wrote:
When I try this

//WebSRFTemplate/Data/Field[Name='SERVICEStaticRoute2IPnetwork1']/text()

I get back the values of ALL Fields in my XML below. I only want the value
(Test1) of the field name specified.

Am I doing something wrong here?
<WebSRFTemplate Version="1" Type="SERVICE">
<Data>
<Field Name="SERVICEStaticRoute2IPnetwork1">"Test1"</Field>
<Field Name="SERVICEStaticRoute3Subnetmask">"Test2"</Field>
<Field Name="SERVICEStaticRoute3IPnetwork1">"Test3"</Field>
<Field Name="SERVICEStaticRoute3">"Test4"</Field>
</Data>
</WebSRFTemplate>

Jun 14 '06 #4

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

Similar topics

1
by: Craig Pearson | last post by:
Hi My function receives an XPathNavigator object. From here I need to build a DataSet to load into SQL Server (using SQLXML adaptor). Does anyone have an idea on the most efficient way to...
7
by: news.microsoft.com | last post by:
Hi, Is the compilation of XSLT, using XPathNavigator.Compile, only beneficial when the returned XPathExpression is cached? Next question, how do I cache the returned XPathExpression object? ...
1
by: Phil | last post by:
Is there an easy way to get the schema's data type for a XPathNavigator value? I need to be able to determine the data type for the xml value based off of an unknown schema and unknown xml file...
1
by: Bruce Dunwiddie | last post by:
I'm trying to build a couple classes that would allow for writing xsl transforms against data that is not originally xml. I've got an xmlreader implementation that seems to work well. Based on some...
7
by: David Thielen | last post by:
Hi; Is there a way from an XPathNavigator object to get an xpath string that will, when used in a Select(xpath) on the underlying base/root XPathNavigator return the same XPathNavigator? In...
12
by: David Thielen | last post by:
Hi; I have an element: <space> </space> When I call SelectSingleNode() on it, the InnerXml is a 0 length String, not a String containing 1 space. Any ideas?
2
by: JSheble | last post by:
I'm integrating with a customer application, and in their assembly, when I call a method it returns data to us as an XPathNavigator object. I can parse the various elements I need out of this...
11
by: ericms | last post by:
Can anybody show me how to insert a CDATA section using XPathNavigator ? I have tried the follwing with no luck: XmlDocument docNav = new XmlDocument(); docNav.LoadXml(xmlString);...
4
by: Bruce Sandeman | last post by:
Hi, Does anyone know how to serialize an XPathNavigator object? I have tried the following but it moans that the xpn does not have a parameterless constructor. XPathNavigator xpn =...
2
by: =?Utf-8?B?Tm9yZW1hYw==?= | last post by:
Hi. Using VS2005, .NET 2.0. I have an xml document that I want to go through and set the values on attributes of elements. The elements are complex types defined in my schema (xsd) files. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.