我有一個具有以下資料格式的文本檔案
<create>
<way id="-200341" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106862"/>
<nd ref="-106343"/>
<nd ref="-107240"/>
<nd ref="-107241"/>
<nd ref="-106863"/>
<nd ref="-106858"/>
<nd ref="-106866"/>
<nd ref="-106263"/>
<nd ref="-106868"/>
<nd ref="-106857"/>
<nd ref="-107242"/>
<nd ref="-106867"/>
<nd ref="-106865"/>
<nd ref="-107243"/>
<nd ref="-107244"/>
<nd ref="-106864"/>
<tag k="shelter" v="yes"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200340" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106853"/>
<nd ref="-106852"/>
<tag k="shelter" v="yes"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200277" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106228"/>
<nd ref="8236806130"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200253" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106766"/>
<nd ref="-106765"/>
<nd ref="-106226"/>
<nd ref="-106769"/>
<nd ref="-106228"/>
<nd ref="-106773"/>
<nd ref="-106230"/>
<nd ref="-106771"/>
<nd ref="-106768"/>
<tag k="highway" v="footway"/>
<tag k="shelter" v="yes"/>
</way>
<way id="-200219" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-107148"/>
<nd ref="-106747"/>
<tag k="shelter" v="yes"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200218" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106766"/>
<nd ref="-106755"/>
<tag k="shelter" v="yes"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200066" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106755"/>
<nd ref="-107148"/>
<nd ref="-106760"/>
<nd ref="-106764"/>
<nd ref="-106762"/>
<nd ref="-107115"/>
<nd ref="-106197"/>
<tag k="highway" v="footway"/>
<tag k="shelter" v="yes"/>
</way>
<way id="543558082" version="1" timestamp="2017-11-29T19:30:02Z" uid="0" user="">
<nd ref="1314909074"/>
<nd ref="5254615443"/>
<nd ref="5254615442"/>
<nd ref="5254615441"/>
<nd ref="5254615440"/>
<nd ref="-106516"/>
<nd ref="5254615439"/>
<nd ref="5254615438"/>
<nd ref="5254615437"/>
<nd ref="5254615436"/>
<nd ref="5254615435"/>
<tag k="service" v="driveway"/>
<tag k="highway" v="service"/>
<tag k="oneway" v="yes"/>
</way>
我有一個std::unordered_map<int, std::string> uMapID_feats{}; 像這樣宣告的 unordered_map 。
假設我的地圖ref="XXXXX"存盤了所有這些 ID 號,并且其中存盤了一個默認字串,例如“unknownplace”。
我想要做的是將 ID(稱為“ ref=XXXXXX”)映射到它下面列出的標簽。所以標簽例如。對于第一個 ID ref=106862,與其相連的標簽是200341, shelter, highway, footway, yes
所以在地圖中,前 3 對看起來像這樣:
"106862" , "200341,shelter,highway,footway,yes"
"106343" , "200341,shelter,highway,footway,yes"
"107240" , "200341,shelter,highway,footway,yes"
有些集比其他集有更多的標簽,而有些只有 2 個標簽,因此我希望將它們全部寫入一個字串并存盤在這個 unordered_map 中,標簽用逗號分隔。
我應該如何決議這些資料并將其正確存盤在 unordered_map 中?
任何幫助表示贊賞,謝謝!
uj5u.com熱心網友回復:
使用像 pluginxml 這樣的 xml 決議庫,或者您可以構建自己的庫。
有很多決議 xml 的庫。選擇一款適合您的需求。這可能對您有所幫助:我應該在 C 中使用什么 XML 決議器?
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/339989.html
