Query problems on Xpath

Asked

Viewed 98 times

3

HTML:

<div align="center"><center>

<table border="0" cellpadding="0">
  <tr>
    <td bgcolor="#006090" valign="top" align="center"><p align="center"><strong><font face="Tahoma"
    size="2" color="#FFFFFF">Selecione a Semana</font></strong></td>
  </tr>
  <tr>
    <td valign="top" align="center" height="1" bgcolor="#22A7D2"><form method="POST">
      <dl>
        <div align="center">
        <dt><font size="2" face="Tahoma">&nbsp;<font color="#FFFFFF"><input type="text" name="EDR" size="20"
          style="background-color: rgb(34,167,210); color: rgb(34,167,210); border: medium none"
          value="Tudo"></font></font></dt>
        </div>
        <dd>&nbsp;</dd>
        <div align="center">
        <dt><strong><font size="2" face="Tahoma">Semana:</font> </strong></dt>
        </div><div align="center">
        <dt><font size="2" face="Tahoma"></font></dt>
        </div>
        <dt><font size="2" face="Tahoma"><strong>&nbsp;&nbsp;&nbsp;&nbsp; </strong><font color="#FFFFFF"><select name="Inicio"
          size="1" style="background-color: rgb(255,255,255); color: rgb(0,0,128)">
            <option value="16/2/2015">16/2/2015 - 22/2/2015 </option>
            <option value="9/2/2015">9/2/2015 - 15/2/2015 </option>

OBS:HTML still has many more options, but so far you can get an idea. The query I’m trying to use to get the value of options(ALL):

//select[name='Inicio']/option/@value

OBS:I couldn’t test the query to see if it worked. When I try to echo in php:

echo $nodes->item(0)->nodeValue;

Error returned:

Notice: Trying to get property of non-object in C:\xampp\

I imagine I’m making a mistake query,have doubt if need be traverse the entire html with the query to get to options or pbone go straight to select as I did. Does anyone know where the mistake is?

  • What returns a $nodes var_dump ?

  • @gmsantos Object(Domnodelist)#41 (1) { ["length"]=> int(0) }

  • Rodolfo, did @Jjoao’s reply solve your problem? Don’t forget to mark it as correct if yes or provide more clarification of what went wrong.

1 answer

1

Almost: one is missing @ in the name; then the consultation, which is so:

//select[name="Inicio"]/option/@value

Should stay that way:

//select[@name="Inicio"]/option/@value
  • @mutlei, thanks. (Sometimes I’m a little too laconic...)

  • You’re welcome. That answer was in the short line of answers, and for good reason hehe.

  • @mutlei, I had tried to answer ...[@name="Inicio"]... but the system didn’t let me.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.