- Moderator
- #1
I have an XML file for email sending that I need to parse.
Normally, this would be pretty straight forward, except this particular file has several entries, with an "IsEnabled" tag....
So, how would I go about finding the first node that is enabled?
Here's (partially) what the file looks like:
... as you can see, the first node has "IsEnabled" set to True, however it may not always be the first node.
So, I guess what I need to do is find the first block with "IsEnabled" set to True, then find the parent of that block, and get the configuration settings from that block.
I know... it should be simple... but I haven't done a lot of XML parsing, especially in C#.
Thanks in advance!
Just my 2ó
"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."
--Greg
Normally, this would be pretty straight forward, except this particular file has several entries, with an "IsEnabled" tag....
So, how would I go about finding the first node that is enabled?
Here's (partially) what the file looks like:
Code:
<SmtpClientsConfiguration xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns:xsd="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
<SmtpDefinitions>
<SmtpClientDefinition>
<SmtpHost>mail.xxxx.net</SmtpHost>
<SmtpPort>25</SmtpPort>
<SmtpUser>user@xxxx.net</SmtpUser>
<SmtpPassword>password</SmtpPassword>
<SmtpDomain />
<SmtpSender>user@xxxx.net</SmtpSender>
<UseSSL>false</UseSSL>
<IsEnabled>true</IsEnabled>
<Timeout>30</Timeout>
</SmtpClientDefinition>
<SmtpClientDefinition>
<SmtpHost>mail.xxxx.org</SmtpHost>
<SmtpPort>25</SmtpPort>
<SmtpUser>user@xxxx.org</SmtpUser>
<SmtpPassword>password</SmtpPassword>
<SmtpDomain />
<SmtpSender>user@xxxx.org</SmtpSender>
<UseSSL>false</UseSSL>
<IsEnabled>false</IsEnabled>
<Timeout>30</Timeout>
</SmtpClientDefinition>
... as you can see, the first node has "IsEnabled" set to True, however it may not always be the first node.
So, I guess what I need to do is find the first block with "IsEnabled" set to True, then find the parent of that block, and get the configuration settings from that block.
I know... it should be simple... but I haven't done a lot of XML parsing, especially in C#.
Thanks in advance!
Just my 2ó
"What the captain doesn't realize is that we've secretly replaced his Dilithium Crystals with new Folger's Crystals."
--Greg