Increasing attributes per element...?

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
Masterhawk
Posts: 299
Joined: Mon Nov 27, 2006 6:52 pm
Location: GERMANY
Contact:

Increasing attributes per element...?

Post by Masterhawk »

hey guys,
for my program I need to create an element node with more than five attributes the standard xml->writeElement() method can write.

So I guessed to extend the native method in this way

Code: Select all

void CXMLWriter::writeElement(const wchar_t* name, bool empty,
	const wchar_t* attr1Name, const wchar_t* attr1Value,
	const wchar_t* attr2Name, const wchar_t* attr2Value,
	const wchar_t* attr3Name, const wchar_t* attr3Value,
	const wchar_t* attr4Name, const wchar_t* attr4Value,
	const wchar_t* attr5Name, const wchar_t* attr5Value,
        //////////EXTENSION////////////////
        const wchar_t* attr6Name, const wchar_t* attr6Value,
	const wchar_t* attr7Name, const wchar_t* attr7Value)
{
	if (!File || !name)
		return;

	if (Tabs > 0)
	{
		for (int i=0; i<Tabs; ++i)
			File->write("\t", 2);
	}
	
	// write name

	File->write(L"<", 2);
    File->write(name, wcslen(name)*2);

	// write attributes

	writeAttribute(attr1Name, attr1Value);
	writeAttribute(attr2Name, attr2Value);
	writeAttribute(attr3Name, attr3Value);
	writeAttribute(attr4Name, attr4Value);
	writeAttribute(attr5Name, attr5Value);

       ////////////EXTENSION///////////////////
       writeAttribute(attr6Name, attr6Value);
       writeAttribute(attr7Name, attr7Value);

	// write closing tag
	if (empty)
		File->write(L" />", 6);
	else
	{
		File->write(L">", 2);
		++Tabs;
	}
}
Does this is a good way or will I get problems with reading the XML-file??

I don't want to recompile the Irrlicht.dll anyway, so if you got a better idea to solve my problem.....just post :wink:

regards masterhawk
Post Reply