Complex conditional clause using XPathMavigator

Hi all,
I have an XML file as follows:
<?xml version="1.0" encoding="UTF-8"?>
<products>
      <product id="1">
            <name>testname</name>
            <productGroup>fpl</productGroup>
            <customers>
                  <customer>Bus Éireann</customer>
                  <customer>Dublin Bus</customer>
            </customers>
            <languages>
                  <language id="de-de" langType="source"/>
                  <language id="en-gb" langType="target"/>
                  <language id="fr-fr" langType="target"/>
                  <language id="it-it" langType="target"/>
            </languages>
            <files>
                  <filename tobetranslated="true" arch="mfc">..\bin\fpl_str.exe</filename>
                  <filename tobetranslated="true" arch="mfc">..\bin\fpl_vdv.exel</filename>
                  <filename tobetranslated="true" arch="java">..\javalibs\de.ivu.mb.fpl.erh.jar</filename>
                  <filename tobetranslated="true" arch="ISA">..\bin\fpl_abf.exe</filename>
                  <filename tobetranslated="true" arch="ISA">..\dlg\fpl_abf.dlg</filename>
            </files>
      </product>
      <product id="2">
            <name>testname2</name>
            <productGroup>fpl</productGroup>
            <customers>
                  <customer>Bus Éireann</customer>
                  <customer>Dublin Bus</customer>
            </customers>
            <languages>
                  <language id="de-de" langType="source"/>
                  <language id="en-gb" langType="target"/>
            </languages>
            <files>
                  <filename tobetranslated="true" arch="mfc">..\bin\fpl_pat.exe</filename>
                  <filename tobetranslated="true" arch="mfc">..\bin\fpl_vdv.dll</filename>
                  <filename tobetranslated="false" arch="mfc">..\bin\fpl_vdv.dll</filename>
            </files>
      </product>
</products>

I need to select the text strings in the all /products/product/files/filename nodes where:
a) the /products/product/files/filename attribute tobetranslated="true" and;
b) the ancestor products/product node contains a languages/language node whose id attribute="en-gb".

Could anyone give me an xpath expression that yields this result?

Thanks very much in advance,

Jaimehy
jaimehyAsked:
Who is Participating?
 
Geert BormansInformation ArchitectCommented:
/products/product[languages/language/@id = 'en-gb']/files/filename[@tobetranslated = 'true']

cheers

Geert
0
 
jaimehyAuthor Commented:
What I want to end up with is a list of all files needing to be translated into English (or whatever language it happens to be) for all products listed in the XML file.
0
 
jaimehyAuthor Commented:
Dim document As XPathDocument
        Dim xPath As XPathNavigator

        document = New XPathDocument("mbfilelist.xml")

        xPath = document.CreateNavigator

        Dim nodes As XPathNodeIterator = xPath.Select("/products/product[languages/language/@id=""en-gb""]/files/filename[@tobetranslated=""true""]")
        While nodes.MoveNext
            FormCreatePSLProject.TextBox1.Text = FormCreatePSLProject.TextBox1.Text & ControlChars.NewLine & nodes.Current.Value
        End While
0
 
jaimehyAuthor Commented:
Jeez Geert,

You're quick.

Thanks.  I've posted the full code I used in VB .Net

Best wishes,

Jaime
0
 
Geert BormansInformation ArchitectCommented:
welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.