Consider the statement A: ホテル(に/で)泊まる. For both cases would translate to "I stay at a hotel" in English. However they are answers to different questions.
Consider the questions 1.どこに泊まる and 2.(ホテルで)何をする
Question 1 would be answered with ホテルに(泊まる), while Question 2 would be answered with (ホテルで)泊まる. The secondary information is presented in parentheses, and can technically be left out. This shows the role of に in marking a location, and the role of で in marking an incidental location where an action occurs.
Consequently, If I present other information using に/で I am in effect emphasizing on the location/action. And for which being more appropriate is dependent on contextual information. (Whether location/action is more important for the listener, or whichever the speaker wants to convey.)
Now consider statement B: 部屋(に/で)泣いている. I am told that I cannot analyze Statement B in the same way as Statement A. I think it's because the verb has been conjugated to its continuative form, and cannot be treated in the same way as Statement A. What happens when I try to ask the two questions of "where" and "what" again?
From Sawa’s answer below, my new understanding is if the verb naturally relates to the location (as in the case of ホテルに泊まる), に should be used. And if it doesn't, で is used.
Consider the following statements. I-部屋に読む, II-部屋で読む, III-図書館に読む, IV-図書館で読む. The verb "read" has no inherent connection with places in general (Reading can be done in a variety of locations). However, "read" is naturally related to "library" as opposed to "room".
Question: So, is II more appropriate than I? And III more appropriate than IV? If it is the case that II>I and III>IV, under what circumstances would I>II and IV>III, and how different would the meaning (or in nuance if any) be in each instance?
Question: For statements containing に or で. Is it true that if に is replaced by で (Or the other way around). The sentence immediately stops making sense and is absolutely wrong? Are there circumstances for which a statement is grammatically correct and has two separate meanings (or nuance) resulting from a (に/で) choice?