Error: 'Imported XML Content cannot be parsed' - google-sheets

Here's what I'm doing:
=IMPORTXML("https://www.predictit.org/api/marketdata/markets/7164", "/MarketData/Contracts/MarketContract/ID")
The other answers I've seen about this have said that Javascript would be the issue, but the page in question seems to load without it, and I've tried using IMPORTJSON and IMPORTFROMWEB to no avail.
Please help!

You are input incorrect parameter for the xmlpath, a proper formula should be as following and you need to spend sometime to find the correct xmlpath to extract the specific string or information you want,
=IMPORTXML("https://www.predictit.org/api/marketdata/markets/7164","//a/#href")
Here is one example from Google:
=IMPORTXML("https://en.wikipedia.org/wiki/Moon_landing", "//a/#href")

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

Getting “#N/A” error when using importhtml formula

I was trying to import a table from hket website to run some analysis of my own.
When I used: =importxml("http://www1.hket.com/finance/chart/industry-index.do","//*[#id='eti-finance-chart-table']") which represents the link to the site, I am getting the "N/A" error.
The importxml works fine with gurufocus site.
Can you help me out? I haven't been able to figure out what the issue could be.
from what I understand, hket doesn't use HTML or XML format for their table. If that is the case, is there a script I can use in Google Sheets that will let me extract data from hket?
you can see the culprit if you run this formula:
=IMPORTXML("http://www1.hket.com/finance/chart/industry-index.do", "//*")

nokogiri and the href label

I am not sure how to access the label part of the anchor href tag. The other question that looks at this doesnt really answer it for me.
I have this code:
#name = page.css("#content").css("a")[1]
Which gives this result
generation xerox
I want to get at the "generation xerox" bit
I wouldnt mind getting at the href, I dont understand that either. I have read several other SO questions but I can't get it to work
Thanks in advance all
You can access the label with #name.text and the link with #name['href']
See doc

How do I link to a LABEL in org-mode?

In org-mode, I have defined a figure+caption like this:
#+CAPTION: My great figure
#+LABEL: fig:myfigure
[[myfigure.png]]
How do I write "See figure [myfigure]"? I've found the following syntax:
See figure \ref{fig:myfigure}
but this looks ugly in the source file. In particular, you cannot use it for actually jumping to the figure.
You actually don't need '#+NAME', it works fine if you use '#+LABEL', which won't break your short-caption for list of figures.
Orgmode does now offer a 'jumpable', enumerated or link with name of your choice in the exported (latex, html) text if you link with:
see figure [[fig:myfigure]].
or
see figure [[fig:myfigure][figurenameintext]].
I would have added this as a comment, but I don't have the reputation yet.
--
In response to your comment (still can't comment): you do need the '#+NAME' for it to jump within the .org source file; as mentioned in the manual, and i also just confirmed that works. Not sure about the short-captions in the latest version.
With a very recent org-mode, you can use #+name:, see:
http://thread.gmane.org/gmane.emacs.orgmode/62644/focus=62646
#+CAPTION: My great figure
#+LABEL: fig:myfigure
#+name: fig:myfigure
[[test.png]]
See figure [[fig:myfigure][test]].
This works for me to jump from the link , but has no effect when exporting, I'm afraid...

Need assistance getting (parsing?) these JSON data into Xcode

Before I start, I would like to say that I'm quite a newbie to Xcode and the C Language, and I'm trying my best to learn as much as I can. I have researched for about 2 days now before posting this question but could not find anything helpful :( I am genuinely stuck and would appreciate ANY help. This is most likely a very simple/basic question:
Basically, I am trying to get this data (LINK) which is apparrently in UTF-8 JSON and display it on a simple label on Xcode. However, I do not know how to get that data and parse it at all. I've followed a tutorial online with success, but that deals with JSON objects rather than arrays (which I think I am dealing with).
I would HIGHLY appreciate it if someone could extract/parse the data from the first link given into a basic label on Xcode in code format.Preferably with commentary on what most lines of code are doing for my own benefit, as this would really help me understand how it works. Hopefully from there, I would be able to make good progress.
Once again this is highly appreciated!
Thank YOu.
Here's a sample of the JSON URL for convenience if you don't want to click the link:
[4,"1.0",1343920773538]
[1,"Spring Gardens","59581","275","Barkingside",1343920940000,1343920940000]
[1,"Spring Gardens","59581","275","Barkingside",1343921717000,1343921717000]
[1,"Spring Gardens","59581","549","Loughton",1343921858000,1343921858000]
[1,"Spring Gardens","59581","275","Barkingside",1343922204000,1343922204000]
[2,"Spring Gardens","59581","8a56a0ab37b72b400137cb7cfd954038_29222",0,3,"Bus routes serving this stop are subject to change during the Olympics and Paralympics games. For more information visit www.tfl.gov.uk/buses for more information.",1344668400000]
Use JSONObject like that tutorial shows, you should get a NSDictionary or NSArray at the end which will contain all your values just map those to the label in the end.
If you dont wan to do that, save the response in a char array and navigate through it while checking for [ or " characters when you find one read the chars until the next occurrence and save all the data you read into an array or something but this is messy and involves atleast 3-4 hours of writing your own custom logic for JSON data decryption, you should use JSONObject which is pretty simple
Hi i have this same problem. I have been looking for a json solution and currently i found that the best way to deal with this data is to parse is as csv instead. The solution seems straight up when you try to parse it as CSV instead of JSON

Resources