ImportXML in Google Sheets, how to get text attributes - google-sheets

I'm a little out of my depth. I have been able to scrape the text/numbers for the XML path I need. However, the text's color is important and has extra meaning. In html, it's listed like this:
<td class="green" title="Charge">10</td>
I can get the 10 with the following XML:
//*#id="dialdiv"]/table[1]/tbody/tr[4]/td/table/tbody/tr[2]/td/div/table/tbody/tr/td[2]/table/tbody/tr[1]/td
How can I capture either the "green" or the "Charge" in addition to the 10?
Thanks!

To get the attribute, add
/#class
assuming your xpath is correct, try
//*#id="dialdiv"]/table[1]/tbody/tr[4]/td/table/tbody/tr[2]/td/div/table/tbody/tr/td[2]/table/tbody/tr[1]/td/#class
and to get both at the same time
//*#id="dialdiv"]/table[1]/tbody/tr[4]/td/table/tbody/tr[2]/td/div/table/tbody/tr/td[2]/table/tbody/tr[1]/td|//*#id="dialdiv"]/table[1]/tbody/tr[4]/td/table/tbody/tr[2]/td/div/table/tbody/tr/td[2]/table/tbody/tr[1]/td/#class

Related

Attempting to import from a XPath, seems to always yield blank information

Currently in my google doc, i'm working on a database for my card worth, and it seems like it doesn't want to grab the information no matter what xpath i want to attempt.
Website i'm trying to take information available here. *This is the hyperlink i'm feeding
In the top right corner i'm attempting to grab the worth box information, here is current xpaths i've attempted
"//a[#id='worthBox']/h4"
"/html/body/div[4]/div[1]/div[2]/form/div[1]/div[2]/div/a/h4"
"/h4"
"/h4[0-20]"
"//a[#id='worthBox'][1]/h4"
"//div[#id='estimate-box']/a/h4"
"//div[#id='estimate-box']/a[1]/h4"
Can someone explain to me why it doesn't seem to wanna fetch, is it even possible?
Thank you so much for your time and help!
In the URL, the value is put using the Javascript. But IMPORTXML cannot retrieve the result after Javascript was run. IMPORTXML retrieves the HTML without running Javascript. I think that your xpath is the result after Javascript was run. By this, they cannot be used. But it seems that the value you expect can be retrieved other xpath.
Modified xpath:
//input[#id='medianHiddenField']/#value
Sample formula:
=IMPORTXML(A1,"//input[#id='medianHiddenField']/#value")
In this case, the URL of https://mavin.io/search?q=Lugia%20NM%209%2F111%20-PSA&bt=sold# put in the cell "A1".
Result:
Reference:
IMPORTXML

How to get phpspreadsheet to fit to page when there is extra space

I have a excel sheet that i'm trying to convert into a pdf. However, whenever I try to use Mpdf, the pdf looks like this.
I get a similar result when using Dompdf:
I've already tried using setFitToPage(1),
setFitToWidth(1),
setFitToHeight(0), and
setPaperSize(\PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::PAPERSIZE_LETTER). Does this have to do more with the excel, or can something be done in phpspreadsheet?
Sometimes there are non visible Characters in a cell. You can try to delete a Colums F-K from your template.

Google ImportXML from QGIS metadata file

I am trying to capture elements of an qmd file (that is xml markup) using Google Sheets importxml. Based on How to use importXML function with a file from Google Drive? I think I've got the file importing correctly but can't seem to capture any of the tags.
Here's what I am trying -
=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","\\identifier")
Here's what the qmd/xml file looks like
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="3.9.0-Master">
<identifier>Z:/My Drive/Mangoesmapping/Spatial Projects/2019/DSC/132_Ongoing_Asset_Updates/Working/Sewerage_Updates/Sewerage_Manholes_InspectionShafts.TAB</identifier>
<parentidentifier>Sewerage Manhole Infrastructure</parentidentifier>
<language>AUS</language>
<type>dataset</type>
<title>Sewerage Manholes within Douglas Shire Council</title>
<abstract>Sewerage Manholes within Douglas Shire Council. Most data has been updated based on field work, review of existing AsCon files and discussion with council staff responsible for the assets in 2018/2019. In Port Douglas most of the infrastructure has been surveyed in. </abstract>
<keywords vocabulary="gmd:topicCategory">
<keyword>Infrastructure</keyword>
<keyword>Sewerage</keyword>
If I use
=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","*")
I get
But I really would like to just get the elements I want by placing the importxml for each tag in the cell I need it in.
You want to retrieve ### of <identifier>###</identifier> from https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download
I could understand like above. If my understanding is correct, how about this answer?
Issue:
In your question, the formula of =importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","\\identifier") uses \\identifier as the xpath. From your data you want to retrieve the values, it seems that you are trying to retrieve ### of <identifier>###</identifier>.
In this case, in order to Selects nodes in the document from the current node that match the selection no matter where they are, // is required to be used instead of \\. This can be seen at the document of here.
Modified formula:
So =importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","\\identifier") can be modified as follows.
=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","//identifier")
As other xpath, from your data in your question, you can also use the xpath of /qgis/identifier instead of //identifier. So you can also use the following formula.
=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","/qgis/identifier")
References:
IMPORTXML
XPath Tutorial

How to fill in a datetime field with capybara?

I found this similar question How to fill in a datetime-local field with capybara?, and the only answer in this thread is not working. So I decided to open this question. It seems like there's no documentation or tutorial about this. Have any solution? It will be a great help!
The keys different browsers accept for setting a datetime input field are diffrent, however if you're using selenium with chrome and you are actually attempting to fill in a visible <input type="datetime-local"> element, as your question states, then the answer in the question your linked to should work - Here is a gist that shows it working - https://gist.github.com/twalpole/a541746b354afde8e82fa89a35a9b2da
The important part in that answer is the format of the string you send since it needs to match the keys the browser is expecting for setting that input (to_json doesn't match that format)
Therefore, in your case of wanting to set DateTime.current it should be something along the lines of
fill_in 'id/name/label of input', with: DateTime.current.strftime("%m%d%Y\t%I%M%P")
If that doesn't work for you then most likely you're not actually attempting to fill a visible <input type="datetime-local"> field (maybe you're using some kind of JS widget that replaces/hides the input???) and you'll need to specify the exact HTML you are trying to fill in your question.
from what I understand, you need to fill in a string representation of the datetime format
examples of such dates are
1990-12-31T23:59:60Z
or
1996-12-19T16:39:57-08:00
so something like
fill_in datetimeinput, with: "1990-12-31T23:59:60Z"
should work (hope so!)

How to get rich text formatting from asana task API

Asana added rich text formatting in June 2014 (https://blog.asana.com/2014/06/rich-text/)
How do you get the formatting metadata from the Asana API?
For example, if I fill in a task description with:
some bold text. some italic text
a list
foo
bar
sublist
a
b
c
baz
The API returns the following for the note field, which excludes any formatting info:
"notes":"some bold text. some italic text\n\na list\n\nfoo\n\nbar\n\nsublist \na\nb\nc\nbaz"
We do not currently support rich text formatting via the API. However if you're feeling adventurous, we are currently working on this support, and you can try it out by using html_notes (for tasks) and html_text (for stories). You can request them using ?opt_fields=html_notes, for example.
Note however that this is still very experimental/early support. If the parser doesn't like the HTML you post, it just strips everything back to plaintext. So this is really only if you're feeling particularly adventurous - otherwise, I'd wait until we release full-fledged public support for it, with documentation and everything.
Is this still something "experimental"? I didn't want to post an answer but it won't let me comment the existing answer. So far I have found:
Acceptable
<b>
<ul>
<li>
Not acceptable:
<h4>
<p>
<div>
<section>
<br>
Any other suggestions for something to do a linebreak? Back in the day, I was using Wufoo to directly create tasks in Asana and it formatted it with a bold heading and then regular text for each entry data. I am trying to achieve this on my own without going that route because I am also updating a database when I receive the form submission. Any ideas on how to format (only the most basic of formatting)?

Resources