ruby - How to specify multiple column by xpath -
i want multiple table data html this:
html = <<eof <table> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> </table> eof
i want 2 data like:
noko = nokogiri::html(html) noko.xpath("//tr[1]/td[2]").text #=> "2" noko.xpath("//tr[1]/td[3]").text #=> "3"
what expect code "23", return "123". how can "23" using xpath?
noko.xpath("//tr[1]/td[2 , 3]").text
there multiple ways of solving problem. 1 :
require 'nokogiri' html = <<eof <table> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> </table> eof noko = nokogiri::html(html) p noko.xpath("//tr[1]/td[position()= 2 or position() = 3]").map(&:text).join # => 23 # way p noko.xpath("//tr[1]/td[2]", "//tr[1]/td[3]").map(&:text).join # => 23
PHP File Upload MIME Type Validation with Error Handling
ReplyDeleteDetect Mobile Devices in PHP
Driving route map
Get Visitor Information by IP Address in PHP
PHP remove HTML and PHP tags from string
how to retrieve encrypted password from database in php
Text to speech in PHP