473,320 Members | 1,841 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,320 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 1748
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.