473,396 Members | 1,859 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,396 software developers and data experts.

xpath help

Hello, I am trying to change app.config via xpath (in a nant script).

The app.config is as follows:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="CRMMetadataServiceUrl" value="devLANI-RF1"/>
</appSettings>
</configuration>

The following xpath

"configuration/appSettings/add[@key = 'CRMMetadataServiceUrl']/@value"
locates the key fine if there is no xmlns attribute on the
'configuration' element, but won't work if the attribute is there. How
can I get to the key if the attribute is there?

Thanks.
Mar 8 '06 #1
1 1659
Frank Rizzo wrote:
Hello, I am trying to change app.config via xpath (in a nant script).

The app.config is as follows:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="CRMMetadataServiceUrl" value="devLANI-RF1"/>
</appSettings>
</configuration>

The following xpath

"configuration/appSettings/add[@key = 'CRMMetadataServiceUrl']/@value"
locates the key fine if there is no xmlns attribute on the
'configuration' element, but won't work if the attribute is there. How
can I get to the key if the attribute is there?

Thanks.


if the attribute of the configuration tag is always the same, you can do
this:

configuration[@xmlns =
"http://schemas.microsoft.com/.NetConfiguration/v2.0"]/appsettings/add[@key
= 'CRMMetadataServiceUrl']/@value

You could also try this:
/appsettings/add[@key = 'CRMMetadataServiceUrl']/@value

i believe in that example, the leading slash means "root element" no
matter what the root element is.
Mar 8 '06 #2

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

Similar topics

0
by: bdinmstig | last post by:
I am building various framework components for my team to use in development, and one of those components is a Facade for reading/writing user preferences. The idea is that preference settings...
0
by: gael.pegliasco | last post by:
Hi, How are you dear and nice helper :) ? I'm trying to test xpath with this simple program : import xml.dom.minidom from xml.xpath.Context import Context import xml.xpath
3
by: Nelson Minar | last post by:
Could someone help me get started using XPath or XQuery in Python? I'm overwhelmed by all the various options and am lacking guidance on what the simplest way to go is. What library do I need to...
13
by: tfsquare | last post by:
All, I am new to XSLT and having some problems understanding the syntax of XPath which selects nodes in the XML document. Consider this bit of XML, which contains three outer XML elements. ...
8
by: Terry P | last post by:
Are there any tools (java classes, tag libraries) which can translate xpath statements into a SQL query? Given an xpath query which has a predicate that filters node values or attributes, I want...
3
by: Kathy Burke | last post by:
Hi again, I'm using the following xpath (works in visualizer) with a SelectSingleNode("xpath") statement. //Station/(WI])]/@order Problem is I get an error "expression passed to this method...
6
by: Chua Wen Ching | last post by:
Hi there, I had this xml file with me (not yet consider implementing xml namespaces yet). <?xml version='1.0'?> <Object> <Windows> <EID>1</EID> <EDesc>Error 1</EDesc> </Windows>
2
by: Locusta | last post by:
Hello, I would like to use XPATH in a C program to retrieve values from XML documents. Did anyone tried this and can give me some advice? Cheers, Locusta
3
by: ziggyware | last post by:
Hi All, I have updated my XPath Generator software: XPath Studio .NET. ( http://www.ziggyware.com/downloads.php?cat_id=2 ) Easily select nodes from an xml file to generate XPath statements ...
2
by: Monty | last post by:
Despite reading posts in Google, I don't understand XPATH. Can someone help me write an XPATH. From Google I think my problem is that the default namespace does not have a prefix. I can't change...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.