Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > regex xpath expressions

Reply
Thread Tools

regex xpath expressions

 
 
Timo Nentwig
Guest
Posts: n/a
 
      02-01-2004
Hi!

Seems that * cannot stand for non-existing nodes, i.e.

/html/*/title

will not match

<html>
<title>won't match</title>
</html>

Isn't it possible to write a xpath that will match the above as well as
<title> encapsulated in <head> (except exp1 | exp2 | expN)?

Regards,
Timo
 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      02-01-2004

"Timo Nentwig" <(E-Mail Removed)> wrote in message
news:bvjhgc$ssfp7$(E-Mail Removed)-berlin.de...
> Hi!
>
> Seems that * cannot stand for non-existing nodes, i.e.


Of course not. It would save time to read a good text in XPath before asking
such kind of questions.

>
> /html/*/title
>
> will not match


An XPath expression does not "match" -- it selects.

>
> <html>
> <title>won't match</title>
> </html>
>
> Isn't it possible to write a xpath that will match the above as well as
> <title> encapsulated in <head> (except exp1 | exp2 | expN)?



The above is not well-formed xml.

What do you mean?


Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html


 
Reply With Quote
 
 
 
 
Timo Nentwig
Guest
Posts: n/a
 
      02-02-2004
Dimitre Novatchev wrote:

> The above is not well-formed xml.


Sure it is. But this doesn't matter anyway.

> What do you mean?


I want one xpath that will select <td> in both cases:

<table>
<tbody>
<tr><td>...
</tbody>
</table>

<table>
<tr><td>...
</table>
 
Reply With Quote
 
Mats Kindahl
Guest
Posts: n/a
 
      02-02-2004
Timo Nentwig <(E-Mail Removed)> writes:

> Dimitre Novatchev wrote:
>
> > The above is not well-formed xml.

>
> Sure it is. But this doesn't matter anyway.
>
> > What do you mean?

>
> I want one xpath that will select <td> in both cases:
>
> <table>
> <tbody>
> <tr><td>...
> </tbody>
> </table>
>
> <table>
> <tr><td>...
> </table>


The XPath expression 'table//td' will match any 'td' with a
'table' node as ancestor.

Best wishes,
Mats Kindahl
--
IAR Systems in Uppsala, Sweden.

Any opinions expressed are my own and not those of my company.

Spam prevention: contact me at http://www.velocityreviews.com/forums/(E-Mail Removed) or
(E-Mail Removed), removing the *NO SPAM* from the address.
 
Reply With Quote
 
Dimitre Novatchev
Guest
Posts: n/a
 
      02-02-2004
"Timo Nentwig" <(E-Mail Removed)> wrote in message news:bvl7oq$ttrfg$(E-Mail Removed)-berlin.de...
> Dimitre Novatchev wrote:
>
> > The above is not well-formed xml.

>
> Sure it is. But this doesn't matter anyway.


That certainly matters!

>
> > What do you mean?

>
> I want one xpath that will select <td> in both cases:
>
> <table>
> <tbody>
> <tr><td>...
> </tbody>
> </table>
>
> <table>
> <tr><td>...
> </table>




These are not well-formed xml documents.

An XPath expression can only be evaluated against a well-formed xml
document.

Unless you provide such, your question has no meaning.

So I have to guess what would be the well-formed xml document you had
in mind.

In case you meant:

<table>
<tbody>
<tr><td/></tr>
</tbody>
</table>

and

<table>
<tr><td/></tr>
</table>


Then one XPath expression (there are many!) thatselects the "td"
element in both cases is:

/table/td | /table/tr/td


Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
How to dynamic XPath expressions in databinding to XmlDataSource? Thor W Hammer ASP .Net 0 03-14-2006 09:08 AM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
mozilla and XPath Expressions Neil Zanella XML 2 12-14-2003 08:14 AM
Add custom regular expressions to the validation list of available expressions Jay Douglas ASP .Net 0 08-15-2003 10:19 PM



Advertisments