PrepAway - Latest Free Exam Questions & Answers

Which XPATH expression should be used?

DRAG DROP
Exhibit:

<ApplicationMenu>
<MenuItem name’Code’>
<MenuItem name=’Region’>
<MenuItem name’Web Site’>
<MenuItem name=’Flamenco’>
<MenuItem name=”Employees”>
<MenuItem name’PassGuide Office”>
</MenuItem>
</MenuItem>
</ApplicationMenu’>
There is MS Visual Studio 2010 and MS .NET Framework 4 application PassGuideApp.
PassGuideApp includes some XML code being displayed in the exhibit.
PassGuideApp uses the Xml Document class to query the XML.
PassGuideApp must return all descendant elements of the specific Menuitem elment that
has a name attribute Flamenco.
Which XPATH expression should be used?

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:

2 Comments on “Which XPATH expression should be used?

  1. John Galt says:

    What a surprise! Another fucked up question. Where do we start? First of all the XML exhibit is shit, thanks to XML tags that are not closed. The answer is screwed up, to the point that you can’t see what’s going on there.

    I’ll try to untangle this mess. I believe the suggested answer is:
    /ApplicationMenu/MenuItem[name=’Flamenco’]/descdentant.MenuItem

    It looks wrong, and it is wrong, tried it in a test application in Visual Studio, and it gave me no results. So I went ahead, and figured out what the answer should be.

    First of all you want to drill down to the ‘Flamenco’ Menu Item, so following XML tree we have:

    /ApplicationMenu/MenuItem[@name=’Flamenco’]

    Note that the choices don’t include ‘@’ symbol, which is wrong. You need ‘@’ to match by attribute.

    The Xpath above will return all contents of MenuItem ‘Flamenco’. But I believe they are looking for separate elements, so you need to use descendants, which gives us the following:

    /ApplicationMenu/MenuItem[@name=’Flamenco’]/descendants::*

    The problem is the possible answers do not include a ‘*’ symbo or doulbe colon. Another alternative could be:
    /ApplicationMenu/MenuItem[@name=’Flamenco’]/descendants::MenuItem

    which would only display MenuItem descendants, so not what the question asks. In any case, I’m guessing this question was copied wrong, so my answer above should get you close enough on the actual exam. Tested both variants of my answer using Visual Studio.

    See the following tutorial on usage of ‘descendants’ axis:
    http://zvon.org/xxl/XPathTutorial/Output/example12.html




    0



    0
    1. Jim BBQ says:

      John you are doing a great work with all these sh!tty questions, thanks!

      When are you going to take an exam? I am going in a week, feel free to contact me if you would like to discuss about it! Look at my “website”




      0



      0

Leave a Reply