Trying to do error cheaking with rapid xml

Ok I know how to parse a rapid xml file. But if I change the xml file xml_nodes then my program crashes.

here is an example of a xml file that I am parsing. This is a file format that I have invented for an editor I am using.

1
2
3
4
5
6
7
8
9
10
11
12
<?xml version="1.0"?>
<sprites>
<layers layername="aname" layercnt="1">
<numberofsprites numofsprites= "2"  numofframes="200">
<properties name="the name of sprite" width="32" height="32" xoffset="10" yoffset="10" depthofsprite="50" animatedsprite="false" intdown="0" intacross="0" animationcnt="0">
<data encodingxpos="cvs">
...
/data>
</numberofsprites>
</layers>
</sprites>


The errors I get when parsing a wrong file are cant parse node, and this an example of the node that crashes the program. let us say that you change layers node to something like this because a user decided too change your file.

<layers layername3="aname" layercnt2="1">

so I want to error check to see if layername is a node or not.

this is the current way i error check
.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
	xmlContents="";
	line="<?xml version=\"1.0\"?>";
	xmlContents=xmlContents+line;
	line="<sprites>";
	xmlContents=xmlContents+line;
	vector<char> checkformat=vector<char>(xmlContents.begin(), xmlContents.end());

	for(int xcnt=0;xcnt<checkformat.size();xcnt++)
	{
		if(checkformat[xcnt]!=xmlData[xcnt])
		{
			
			return;
		}
	}

It only checks the first 2 lines of the opened xml file.
Last edited on
Post some more code and i will walk thru it. Did u check the length on xmlContents ?
Topic archived. No new replies allowed.