# Import from url question — “Cannot import data as Graph6 format”

When I import url, there will show the folling message:

"Cannot import data as Graph6 format"

The codes as following:

Import["http://pubsonline.informs.org/doi/abs/10.1287/mksc.14.3.G6","XMLObject"]


But the another url will work:

 Import["http://pubsonline.informs.org/doi/abs/10.1287/mksc.14.3.G20","XMLObject"]


I don't know why it happend, I can visit the website directly. I guess the ".G6" is the problem, but I don't know how the solve it.

I change "XMLObject" to "HTML" (by Szabolcs), but the return datas is different with "XMLObject".

• Note that this is HTML, not XML. Trying to import as XML would fail. – Szabolcs Dec 3 '17 at 12:22

To make this work, you need to specify the format. There is no "XMLObject" format. "XMLObject" is an import element for the "HTML" and "XML" (and perhaps some other) formats. Thus when you only specify "XMLObject", Mathematica is still trying to auto-detect the format. In this case, it will try to import the file as the Graph6 format, which won't work for a HTML document.

Specify the format explicitly as "HTML" and also specify the import element, i.e. that you want the result as an "XMLObjct".

Import["http://pubsonline.informs.org/doi/abs/10.1287/mksc.14.3.G6", {"HTML", "XMLObject"}]


Note that this is exactly the same mistake as using Import["somefile", "Data"], which is unfortunately all too commonly seen on this site. "Data" isn't a format either, and when you use it, you are betting on the success of format detection.

• Thank you for your answer, I changed the question, and add another url, it will work. I don't know why. – zongxian Dec 3 '17 at 12:36
• @zongxian Because it doesn't end in .g6, so the result of the auto-detection is not the Graph6 format. As I said in the answer, if you leave it up to Mathematica to guess the format, it might or it might not get it right. You are relying on luck. – Szabolcs Dec 3 '17 at 12:40
• I tried your method, but the return contents is different, I will add a image in the question. – zongxian Dec 3 '17 at 12:52
• @zongxian You did not read the answer carefully and did something else than what I suggested. – Szabolcs Dec 3 '17 at 12:58
• I know your mean is there is no "XMLObject", I use it is wrong, but how can I know the website is a "html" or "XML", MMa auto check it and return datas, but if I use "html", it return the different contents with "XMLObject", as I am a new user, so I don't knon how to get the same content as use the wrong parameter of "XMLObject". – zongxian Dec 3 '17 at 13:04