NAnt issue - unsuccessful in using xpath expression with xmlpoke

C

chrisjaycomer

I have successfully setup numerous xmlpoke statements within an Nant
script but this specific situation I cannot figure out. I am including



a section of the xml code I am trying to access and update using an
xmlpoke statement. No matter what I try I continue to get "
[xmlpoke] No matching nodes were found with XPath
expression '/log
gingDistributorConfiguration/xmlSerializerSection/enterpriseLibrary.logging­­DistributorSettings'.



Below is the error message, xml file I am trying to modify and the
corresponding xmlpoke expression which fails.


Error Message


[xmlpoke] No matching nodes were found with XPath expression
'/loggingDistributorConfiguration/xmlSerializerSection/enterpriseLibrary.lo­­ggingDistributorSettings'.



xmlpoke expression


<xmlpoke


file="..\src\LetterProcessingMonitor\loggingDistributorConfiguration.config­­"



xpath="/loggingDistributorConfiguration/xmlSerializerSection/enterpriseLibr­­ary.loggingDistributorSettings"



value="test" />


XML


<?xml version="1.0" encoding="utf-8"?>
<loggingDistributorConfiguration>
<xmlSerializerSection
type="Microsoft.Practices.EnterpriseLibrary.Logging.Distributor.Configurati­­on.DistributorSettings,



Microsoft.Practices.EnterpriseLibrary.Logging, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null">
<enterpriseLibrary.loggingDistributorSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"



defaultCategory="General" defaultFormatter="Text Formatter"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/loggi...">



<sinks>
<sink xsi:type="FlatFileSinkData" name="Flat File Sink"
fileName="LPM_log.txt" header="" footer="" />
</sinks>
<categories>
<category name="General">
<destinations>
<destination name="Event Log Destination" sink="Event Log
Sink" format="Text Formatter" />
</destinations>
</category>
<category name="Category">
<destinations>
<destination name="My First Destination" sink="Flat File
Sink" format="Text Formatter" />
</destinations>
</category>
</categories>
<formatters>
<formatter xsi:type="TextFormatterData" name="Text Formatter">
<template><![CDATA[{timestamp} | {processId} |
{win32ThreadId} | {message} ]]></template>
</formatter>
</formatters>
</enterpriseLibrary.loggingDistributorSettings>
</xmlSerializerSection>
</loggingDistributorConfiguration>
 
C

chrisjaycomer

Tasos thank you for your reply.

Actually I may have not been clear enough in my original posting. What
I ultimately want to alter is the filename attribute under the sink
element as posted below. Is this something you could help me with?

<sink xsi:type="FlatFileSinkData" name="Flat File Sink"
fileName="LPM_log.txt" header="" footer="" />
 
T

Tasos Vogiatzoglou

<enterpriseLibrary.loggingDistributorSettings defines a default xmlns
thats why the xpath query does not return a node.

What you should do is to create an xpath query based on the local name
of the node you are searching (as I dunno any way you could specify a
default namespace).

I had the same issue (code wise) with the configuration files of the MS
App Blocks and I used string replace :) .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top