从.config文件中删除特定元素
我正在尝试从软件的配置文件中删除特定元素。它的格式类似于我以前可以解析的XML,但这一次似乎有所不同。由于它并没有真正包含任何敏感信息,因此我将在此处将配置文件放在我需要删除的元素中。对不起,很长的帖子。
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
...
</sectionGroup>
</configSections>
<startup>
...
</startup>
<runtime>
...
</runtime>
<system.net>
...
</system.net>
<applicationSettings>
<SoD.Settings>
<!-- SpeechAnywhere Services (SAS) Server URL.
For the Nuance hosted SAS instance, use https://sas.nuancehdp.com/basic
For on-premise deployments specify a URL using the format (http|https)://your.server.instance:port/basic?mode=1 -->
<setting name="ServerURL" serializeAs="String">
...
</setting>
<!-- Organization token -->
<setting name="OrganizationToken" serializeAs="String">
...
</setting>
<!-- Added Paragon Fix -->
<setting name="RapidNavigationPrecisionTuning" serializeAs="String">
...
</setting>
<setting name="SupportedDomains" serializeAs="String">
...
</setting>
<setting name="SupportedAccounts" serializeAs="String">
...
</setting>
<!-- Please ensure that the microphones available to end users produce high quality sound. The list of microphones,
presented to users, should be short and limited to models recommended by Nuance or verified by you with the application.
If you have any questions, contact your Nuance Professional Services representative. -->
<setting name="AllowedMicrophones" serializeAs="String">
...
</setting>
<!-- Languages in the IETF format. To present a list of available languages
to the end user, specify all supported languages in the setting and separate them
with the pipe (|) character (for example, de-DE|en-US|sv-SE|nl-BE). -->
<setting name="SupportedLanguages" serializeAs="String">
...
</setting>
<!-- Speech recognition topic(s). If you want to present a list of available speech recognition
topics to the end user, specify all supported speech recognition topics in the setting and
separate them with the pipe (|) character (for example, GeneralMedicine|Surgery). -->
<setting name="SupportedTopics" serializeAs="String">
...
</setting>
<setting name="EULAHasBeenAcceptedByAllUsers" serializeAs="String">
...
</setting>
<!--
Authentication (none/native/ldap/ldaplocal/trusted/sso/sso_adfs)
none : No authentication (default)
native : NMS Native
ldap : LDAP/AD
ldaplocal : LDAP local authentication
trusted : Trusted
sso : SSO via Central Authentication
sso_adfs : SSO via ADFS Authentication
-->
<setting name="Authentication" serializeAs="String">
<value>trusted</value>
</setting>
我需要在最后删除“受信任的”值,但似乎无法找到一种找到它的方法。我仍然是所有这些。谢谢!
I am trying to remove a specific element from a piece of software's config file. It is formatted similar to an XML, which I have been able to parse before, but it seems to be a little different this time. As it doesn't really contain any sensitive info, I will just put the config file here up to the element I need to remove. Sorry for the long post.
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
...
</sectionGroup>
</configSections>
<startup>
...
</startup>
<runtime>
...
</runtime>
<system.net>
...
</system.net>
<applicationSettings>
<SoD.Settings>
<!-- SpeechAnywhere Services (SAS) Server URL.
For the Nuance hosted SAS instance, use https://sas.nuancehdp.com/basic
For on-premise deployments specify a URL using the format (http|https)://your.server.instance:port/basic?mode=1 -->
<setting name="ServerURL" serializeAs="String">
...
</setting>
<!-- Organization token -->
<setting name="OrganizationToken" serializeAs="String">
...
</setting>
<!-- Added Paragon Fix -->
<setting name="RapidNavigationPrecisionTuning" serializeAs="String">
...
</setting>
<setting name="SupportedDomains" serializeAs="String">
...
</setting>
<setting name="SupportedAccounts" serializeAs="String">
...
</setting>
<!-- Please ensure that the microphones available to end users produce high quality sound. The list of microphones,
presented to users, should be short and limited to models recommended by Nuance or verified by you with the application.
If you have any questions, contact your Nuance Professional Services representative. -->
<setting name="AllowedMicrophones" serializeAs="String">
...
</setting>
<!-- Languages in the IETF format. To present a list of available languages
to the end user, specify all supported languages in the setting and separate them
with the pipe (|) character (for example, de-DE|en-US|sv-SE|nl-BE). -->
<setting name="SupportedLanguages" serializeAs="String">
...
</setting>
<!-- Speech recognition topic(s). If you want to present a list of available speech recognition
topics to the end user, specify all supported speech recognition topics in the setting and
separate them with the pipe (|) character (for example, GeneralMedicine|Surgery). -->
<setting name="SupportedTopics" serializeAs="String">
...
</setting>
<setting name="EULAHasBeenAcceptedByAllUsers" serializeAs="String">
...
</setting>
<!--
Authentication (none/native/ldap/ldaplocal/trusted/sso/sso_adfs)
none : No authentication (default)
native : NMS Native
ldap : LDAP/AD
ldaplocal : LDAP local authentication
trusted : Trusted
sso : SSO via Central Authentication
sso_adfs : SSO via ADFS Authentication
-->
<setting name="Authentication" serializeAs="String">
<value>trusted</value>
</setting>
I need to remove the 'Trusted' value at the very end, but cant seem to figure out a way to find it. I am still very new to all of this. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果该值始终存在于其自己的线上,那么您不妨将其剪切而不是解析XML:
If that value always exists on its own line, then you might as well just cut it rather than parse the xml: