Shelly Midha asked:

> I'm using <xmlpeek> to read xml configuration file. 
> I want to retreive the 'value' for given value of <name>

Well, I've never used xmlpeek - but I do develop XSLT stylesheets, so I
understand XPATH expressions.

> <xmlpeek verbose="false" file="${DB.DBFilePath}" 
>          xpath="/parameters/parameter/name" 
>          property="DB.DataFilePath" /> 

The XPATCH expression "/parameters/parameter/name" is working correctly
- both of the parameters are matching.

You need to add some kind of predicate to your XPATH expression to only
match one parameter.

One way is to match based on index, something like this:

> <xmlpeek verbose="false" file="${DB.DBFilePath}" 
>          xpath="/parameters/parameter[1]/name" 
>          property="DB.DataFilePath" /> 

However, this will fail if the your XML file is changed, as it's hard
coded to retrieve the first parameter, no matter it's name.

This might be better:

> <xmlpeek verbose="false" file="${DB.DBFilePath}" 
>          xpath="/parameters/parameter[name = 'DATA_FILE_DIR']/value" >        
>   property="DB.DataFilePath" /> 

Ie: Give me the Value of the Parameter with name 'DATA_FILE_DIR'.

Caveats: 
(i) These examples are written of the cuff, so to speak, so they're
completely untested.
(ii) I normally write XSLT for the Apache Xalan XSLT processor; there
may be some differences between it and the MSXML processor used by NAnt.

Hope this helps,
Bevan.


******************************************************************************
"This message (and any files transmitted with it) are confidential and 
may be legally privileged. If you are not the intended recipient please
notify the sender immediately and delete this message from your system.

This message does not necessarily reflect the views of the
Reserve Bank of New Zealand. If the recipient has any concerns
about the content of this message they should seek alternative
confirmation from the Reserve Bank of New Zealand."
******************************************************************************





-------------------------------------------------------
SF.Net email is sponsored by: GoToMeeting - the easiest way to collaborate
online with coworkers and clients while avoiding the high cost of travel and
communications. There is no equipment to buy and you can meet as often as
you want. Try it free.http://ads.osdn.com/?ad_idt02&alloc_id135&op=click
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to