Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » how to use xmlparser to parse this document?
how to use xmlparser to parse this document? [message #49120] Wed, 20 December 2017 04:00 Go to previous message
akebee is currently offline  akebee
Messages: 90
Registered: August 2011
Location: China
Member
i still do not quite understand the use of XmlParser Embarassed
such as parse this xml document:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>frames</key>
        <dict>
            <key>Comm1TipBg.png</key>
            <dict>
                <key>frame</key>
                <string>{{314,805},{120,120}}</string>
                <key>offset</key>
                <string>{0,0}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{0,0},{120,120}}</string>
                <key>sourceSize</key>
                <string>{120,120}</string>
            </dict>
            <key>Common1Back.png</key>
            <dict>
                <key>frame</key>
                <string>{{791,462},{62,54}}</string>
                <key>offset</key>
                <string>{0,0}</string>
                <key>rotated</key>
                <true/>
                <key>sourceColorRect</key>
                <string>{{0,0},{62,54}}</string>
                <key>sourceSize</key>
                <string>{62,54}</string>
            </dict>
            <key>Common1Button1.png</key>
            <dict>
                <key>frame</key>
                <string>{{766,257},{132,64}}</string>
                <key>offset</key>
                <string>{0,0}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{0,0},{132,64}}</string>
                <key>sourceSize</key>
                <string>{132,64}</string>
            </dict>
            <key>Common1Button1Disable.png</key>
            <dict>
                <key>frame</key>
                <string>{{314,927},{132,64}}</string>
                <key>offset</key>
                <string>{0,0}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{0,0},{132,64}}</string>
                <key>sourceSize</key>
                <string>{132,64}</string>
            </dict>
            <key>Common1Button2.png</key>
            <dict>
                <key>frame</key>
                <string>{{149,955},{132,64}}</string>
                <key>offset</key>
                <string>{0,0}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{0,0},{132,64}}</string>
                <key>sourceSize</key>
                <string>{132,64}</string>
            </dict>
            <key>Common1Button3.png</key>
            <dict>
                <key>frame</key>
                <string>{{559,514},{109,52}}</string>
                <key>offset</key>
                <string>{0,0}</string>
                <key>rotated</key>
                <true/>
                <key>sourceColorRect</key>
                <string>{{0,0},{109,52}}</string>
                <key>sourceSize</key>
                <string>{109,52}</string>
            </dict>
            <key>CommonVipSmall09.png</key>
            <dict>
                <key>frame</key>
                <string>{{937,823},{58,22}}</string>
                <key>offset</key>
                <string>{0,0}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{0,0},{58,22}}</string>
                <key>sourceSize</key>
                <string>{58,22}</string>
            </dict>
            <key>CommonVipSmall10.png</key>
            <dict>
                <key>frame</key>
                <string>{{917,799},{58,22}}</string>
                <key>offset</key>
                <string>{0,0}</string>
                <key>rotated</key>
                <false/>
                <key>sourceColorRect</key>
                <string>{{0,0},{58,22}}</string>
                <key>sourceSize</key>
                <string>{58,22}</string>
            </dict>
        </dict>
        <key>metadata</key>
        <dict>
            <key>format</key>
            <integer>2</integer>
            <key>realTextureFileName</key>
            <string>Common1.png</string>
            <key>size</key>
            <string>{1024,1024}</string>
            <key>smartupdate</key>
            <string>$TexturePacker:SmartUpdate:dc2b5d576da62f910d03eadb09babf4b$</string>
            <key>textureFileName</key>
            <string>Common1.png</string>
        </dict>
    </dict>
</plist>


my code Crying or Very Sad
	XmlParser pser(plist);
	pser.Relaxed();
	try{
		while(!pser.IsTag())
			pser.Skip();
		pser.PassTag("plist");
		pser.PassTag("dict");
		while(!pser.IsEof())
			if(pser.Tag("key"))
			{
				String key = pser.ReadText();
			//	DUMP(key);
				pser.PassEnd();
			}
			else if(pser.TagElseSkip("dict"))
			{
				while(!pser.IsEof())
				{
					if(pser.Tag("key"))
					{
						String key = pser.ReadText();
						DUMP(key);
						pser.PassEnd();
					}	
					else if(pser.Tag("dict"))
					{
					}
					else
						pser.Skip();			
				}
				pser.PassEnd();
			}
			
	}
	catch(XmlError e){
		LOG("ERROR: " << e);
	}
Crying or Very Sad Crying or Very Sad
 
Read Message
Read Message
Previous Topic: Fixes to Array::Create & Vector::Create
Next Topic: ParseJSON now throws exception
Goto Forum:
  


Current Time: Fri Apr 19 08:33:57 CEST 2024

Total time taken to generate the page: 0.03789 seconds