Anusha:

You say you want the contents of the <c> node, but your code is asking for nodes containing a space. When writing code for Xpath, perl or any other language, you need to write code that asks for exactly what you want, rather than rather than trying to hack together an unrelated request that may--by chance--give you the result you wanted.

I haven't done Xpath in quite a while, so I don't recall the syntax, but google led me to a couple sites with Xpath examples. It appears that asking for a specific node type is more like: //nodetype, so in your case you'd use //c. If you want X but ask for Y, don't be surprised when you get useless results. If you don't know how to ask Xpath (or any other language) the right question, google is but a few keystrokes away.

Update: After seeing AM's response, I realize your search criterion may be to find nodes containing multiple contiguous blanks. In that case, you could use //*[*contains(.,"  ")] (Note: two blanks), and if you're using XPath 2.0, you could use a regex: //*[*matches(.,'\s\s')]. (Note: I've not tested these, so they may need tweaking.

Update 2: choroba has an even better answer--I didn't even consider the "between words" clause.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: Need help for Xpath patterns by roboticus
in thread Need help for Xpath patterns by Anusha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.