我有一個字符串:獲取兩個字符串之間的字符串?
<products type="array">
<product><brand>Rho2</brand>
<created-at type="datetime">2011-11-03T21:29:46Z</created-at><id type="integer">78013</id><name>Test2</name>
<price nil="true"/>
<quantity nil="true"/>
<sku nil="true"/>
<updated-at type="datetime">2011-11-03T21:29:46Z</updated-at>
</product>
<product>
<brand>Apple</brand>
<created-at type="datetime">2011-10-26T21:26:59Z</created-at>
<id type="integer">77678</id>
<name>iPhone</name>
<price>$199.99</price>
<quantity>5</quantity>
<sku>1234</sku>
<updated-at type="datetime">2011-10-26T21:27:00Z</updated-at>
</product>
我想<brand>
和</brand>
之間的文本。
我想解析這個XML,收集標籤之間的數據。
你寫「之間,並得到文本。 「 - 也許你錯過標籤名稱? – WarHog
你的問題沒有多大意義。是否有理由不能僅僅使用任意數量的庫中的任何一個來解析XML,然後合理地檢索數據? – muffinista
REXML或XmlSimple應該這樣做。是的,XML可以在一個字符串中,它仍然會解析。周圍有更多的圖書館。這裏有一個[工作示例](http://xml-simple.rubyforge.org/)。 – abhinav