using XmlReader reader to extract an elemen in correlation with another element

Hi all
The xml file below has two different mimeType
in the Attachments node
1:  <mimeType>application/pdf</mimeType>
 2: <mimeType>application/pdf</mimeType>
I am looking for a way to get the value in content If and only if the value of mimeType
is "application/pdf"

Thanks in Advance

If (mimeType = "application/pdf")
    varOutputString = (reader.ReadElementContentAsString());

using (XmlReader reader = XmlReader.Create(new StringReader(xmlString)))
    string genre = reader.Value;
If (mimeType = "application/pdf")
    varOutputString = (reader.ReadElementContentAsString());

Open in new window

<?xml version="1.0" encoding="iso-8859-1"?>
      <Description>Validation Result</Description>

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carl TawnSystems and Integration DeveloperCommented:
This seems like something that would be more easily achieved using an XmlDocument and an XPath expression. Is that something you're open to, or do you specifically need to use an XmlReader?
ZURINETAuthor Commented:
Just solved it..

 <xsl:for-each select="Data/Attachments">
              <xsl:variable name="var:v1" select="userCSharp:LogicalEq(string(mimeType/text()) , &quot;application/pdf&quot;)" />
              <xsl:if test="$var:v1">
                    <xsl:value-of select="Content/text()" />

Open in new window

ZURINETAuthor Commented:
Hi carl_tawn

May I see how you solution might look like?
Carl TawnSystems and Integration DeveloperCommented:
Very simply:
            string file = @"C:\temp\test.xml";

            XmlDocument doc = new XmlDocument();

            XmlNodeList list = doc.SelectNodes("//Attachments[mimeType='application/pdf']/Content");

            foreach (XmlNode node in list)

Open in new window

But if you can use XSLT to achieve your aim then that works too.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZURINETAuthor Commented:
Solve my problem
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.