A peculiar feature of the German language is that leaving out articles will generally produce a grammatically correct German sentence, provided that all adjectives are switched to strong inflection. You might recall the inflection tables for German adjectives here. For example,
Ich esse hölzernen Schrank mit gebrauchter Autoreifen als Nachtisch. Es besteht erhöhte Zahnschmerzgefahr.
is grammatically correct.
It is a different question whether statement without article in front of nouns is meaningful. Typically, a noun in German has no article if it is uncountable, as is the case with 'mass nouns' such as
Wasser, Holz, Honig, Milch, Diamant, Gold, Wärme, Kälte, Gewebe, Kunst, Wissen
You will notice some of those words might (rarely or frequently) appear with an article or not. The rule of thumb is that a noun without article refers to a diffuse, unquantified, abstract idea, whereas a noun with article refers to something particular. I presume it depends on the context what a noun means without an article, but it should be related to its meaning when putting 'etwas' in front of it.
That all being said, Heine's grammar is fully correct. But consider the statement
Auf grünem Holz sitzt und singt die süße Philomele.
which is an absolutely contemporary usage of "Holz" without article. It sounds a bit like a Heine is writing more about the material rather than the particular tree. However, with that meaning, Philomele is sitting on green limewood. So probably Heine just played with the grammar for the sake of poetry.