Sascha,

Because of xmlns=“http://docbo…” in the outer ‘info’ node, you need to specify 
that namespace with SelectSingleNode.  To do so, you also need an 
XmlNamespaceManager.

var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace(“whatever", "http://docbook.org/ns/docbook";);
var productNumberNode = doc.SelectSingleNode(“//whatever:productnumber", nsmgr);

-Dave

> On Feb 7, 2017, at 11:15 AM, Sascha Manns <[email protected]> wrote:
> 
> Hello list,
> 
> i have a DocBook file with that content:
> 
> <info version="5.0" xml:id="info-Documentation-Test-Test" 
> xmlns="http://docbook.org/ns/docbook <http://docbook.org/ns/docbook>" 
> xmlns:xlink="http://www.w3.org/1999/xlink"; <http://www.w3.org/1999/xlink%22>>
> ...
> <productnumber>0.1</productnumber>
> ...
> </info>
> 
> My goal now is to replace that number with another. I tried:
> 
> XmlDocument xmlDoc = new XmlDocument();
> xmlDoc.Load(info);
> xmlDoc.SelectSingleNode("//productnumber").InnerText = revnumber;
> xmlDoc.Save(info);
> 
> The info variable targets to the mentioned file above.
> 
> If i'm running my code i'm getting:
> 
> Exception in Gtk# callback delegate
>   Note: Applications can use GLib.ExceptionManager.UnhandledException to 
> handle the exception.
> System.Reflection.TargetInvocationException: Exception has been thrown by the 
> target of an invocation. ---> System.NullReferenceException: Object reference 
> not set to an instance of an object
>   at PublicanCreators.Core.RevUpd.ChangeRevision (System.String revnumber, 
> System.String articleInfo, System.String bookInfo) [0x0003e] in 
> /home/sascha/RiderProjects/PublicanCreators/src/PublicanCreators.Core/RevUpd.cs:85
>  
> 
> Maybe anyone knows how to fix that?
> 
> Greetings
> Sascha
> 
> _______________________________________________
> Mono-list maillist  -  [email protected]
> http://lists.dot.net/mailman/listinfo/mono-list

_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.dot.net/mailman/listinfo/mono-list

Reply via email to