2
$\begingroup$

I import a dataset from the internet like:

data=Import["http://www.test.com", {"HTML", "XMLObject"}]

The dataset looks like this:

{"02 jan", "40,250", "40,400", "40,150", "40,590", "152.289"
.....
"27 jan", "39,900", "39,560", "39,130", "39,910", "265.867"
, XMLElement["span", {"class" -> "ValueDown"}, {"-1,090"}]
, XMLElement["span", {"class" -> "ValueDown"}, {"-2,68%"}]
, "28 jan", "39,730", "40,080", "39,270", "40,080", "207.516"
, XMLElement["span", {"class" -> "ValueUp"}, {"+0,520"}]
, XMLElement["span", {"class" -> "ValueUp"}, {"+1,31%"}]
, "29 jan", "40,030", "40,170", "39,890", "40,460", "189.669"
...
, XMLElement["span", {"class" -> "ValueDown"}, {"-0,90%"}]
, XMLElement["span", {}, {"10 feb"}], XMLElement["a", {"shape" -> "rect", 
  "title" -> "Beleggen in vastgoed? Dit zijn de opties", 
  "href" -> "http://www.test.nl/text/493371/text.aspx", 
  "target" -> "_blank"}, {"text"}], XMLElement["span", {}, {"07 feb"}],
....
};

I used "....." to show that in real the dataset us much bigger. Now I want to select the left part until the string: XMLElement["span", {}, {"10 feb"}].

Who has a suggestion how to fix this?

$\endgroup$
  • $\begingroup$ position = Position[data, XMLElement["span", {}, {"10 feb"}]]; data[[;; position - 1]] $\endgroup$ – Rohit Namjoshi Feb 11 at 14:27
  • 2
    $\begingroup$ What is your desired outcome? data/.XMLElement[__]:> Nothing or each left-part match in a separate list? Also a minimum working example would be useful. $\endgroup$ – user1066 Feb 11 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.