XPath Queries

evanshevansh Member Posts: 6 Contributor II
edited November 2018 in Help
Hello All,

I'm trying to extract several values from html files that I pulled from DrugBank.com using the Web Crawling operator. For your reference, each file in my folder resembles the following web page: http://www.drugbank.ca/drugs/DB01048

I've managed to use the Extract Information Operator and XPath queries to successfully pull values such as "Mechanism of Action" and "Indication", and add them as attributes in an example set. However, I'm failing again and again to do the same for the "Categories" field. I'd ideally like to extract the "button label" on the hyperlink, not the URL. So for the example page above I'd like to create two new attributes with the values "Anti-HIV Agents" and "Reverse Transcriptase Inhibitors". However, I'm consistently getting either blank columns or question marks.

Thanks in advance for any assistance.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="6.5.001">
  <operator activated="true" class="process" compatibility="6.5.001" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="text:process_document_from_file" compatibility="6.5.000" expanded="true" height="76" name="Process Documents from Files" width="90" x="112" y="30">
        <list key="text_directories">
          <parameter key="DB Crawl Files" value="/Users/hardyevans/Desktop/SSR Research/Novelty/DB Crawl"/>
        <parameter key="extract_text_only" value="false"/>
        <parameter key="create_word_vector" value="false"/>
        <process expanded="true">
          <operator activated="true" class="text:extract_information" compatibility="6.5.000" expanded="true" height="60" name="Extract Information" width="90" x="112" y="30">
            <parameter key="query_type" value="XPath"/>
            <list key="string_machting_queries"/>
            <list key="regular_expression_queries"/>
            <list key="regular_region_queries"/>
            <list key="xpath_queries">
              <parameter key="Mechanism Of Action" value="//h:*[contains(.,'Mechanism of action')]/../h:td[last()]/text()"/>
              <parameter key="Indication" value="//h:*[contains(.,'Indication')]/../h:td[last()]/text()"/>
              <parameter key="Pharmacodynamics" value="//h:*[contains(.,'Pharmacodynamics')]/../h:td[last()]/text()"/>
              <parameter key="Description" value="//h:*[contains(.,'Description')]/../h:td/h:p[last()]/text()"/>
            <list key="namespaces"/>
            <list key="index_queries"/>
            <list key="jsonpath_queries"/>
          <connect from_port="document" to_op="Extract Information" to_port="document"/>
          <connect from_op="Extract Information" from_port="document" to_port="document 1"/>
          <portSpacing port="source_document" spacing="0"/>
          <portSpacing port="sink_document 1" spacing="0"/>
          <portSpacing port="sink_document 2" spacing="0"/>
      <operator activated="true" class="store" compatibility="6.5.001" expanded="true" height="60" name="Store" width="90" x="313" y="30">
        <parameter key="repository_entry" value="Scraped DB Files"/>
      <connect from_op="Process Documents from Files" from_port="example set" to_op="Store" to_port="input"/>
      <connect from_op="Store" from_port="through" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
Sign In or Register to comment.