2
$\begingroup$

I want to get the SVG format about this <table> element in this page. It looks like this:

enter image description here

But I want to get it with a SVG image by Mathematica. Now I can get its HTML string:

url = "http://www.badd-cao.net:2345/browse/compound/C0283";
object = Cases[Import[url, "XMLObject"], 
   XMLElement["table", {_, "id" -> "target_relate_table"}, _], Infinity];
tablehtml = ExportString[First[object], "XML"]

enter image description here

But How to export it into my dist as an SVG image?

$\endgroup$

1 Answer 1

3
$\begingroup$

You can import it as a Dataset, then use Export.

dataset = Dataset[Import[url, {"HTML", "Data"}][[2]], MaxItems -> All];
Export["Table.svg", dataset];

enter image description here

$\endgroup$
2
  • $\begingroup$ Elegant method, and make a note here:ImportString[tablehtml,{"HTML","Data"}] or Import[url,{"HTML","Data",2}] $\endgroup$
    – yode
    Mar 7, 2023 at 17:26
  • $\begingroup$ It would be nice to be able to select a particular table with the specified id $\endgroup$
    – yode
    Mar 8, 2023 at 2:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.