简体   繁体   中英

c# select single node xpath returns null

I have an app config in ac# project I need to edit at run time. As part of this I have a custom section collection I need to select a single node for. This is the xml and selection statement from my immediate window:

node = xmlDoc.SelectSingleNode("//Customers/add[@id='1']");  

null

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="customers" type ="ImporterSupport.CustConfigSection, ImporterSupport"/>
    </configSections>
    <customers>
        <add id ="1" license="gh620g0g0g0g0g3p" ServerAddress ="localhost"  ServerPort="8292" SettingsFile ="AutoImportTest.txt" Confirm ="false" DisableRemoveRecips="true" DisableRecoverRecips="true" DisableAlphaId ="true" />
    </customers>
</configuration>

Xml is case sensitive. Use

var node = xmlDoc.SelectSingleNode("//customers/add[@id='1']");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM