Official Murl Engine Forum

Full Version: Location/Reading custom xml files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I have some questions regarding custom xml files.

What I want is to read custom xml config files.
I guess the perfect location would be inside .murlres package.

Reading and parsing xml files using Murl::Util::FileTools::LoadBinaryFile and Murl::Util::XmlParser works great, but my question is how to open the file when it's inside a .murlres package?

If the .murlres package is the wrong choice what would be the right one?


The .murlres package can easily be used to host any type of custom files. Simply specify your resource inside the package.xml file using the type="BINARY" attribute:
<?xml version="1.0" ?>
<Package id="Main">
    <Resource type="BINARY" id="MyXmlFile" fileName="my_fancy_file.xml"/>

You can then access that file from e.g. a logic class' OnInit() method like this:
Bool App::MyLogic::OnInit(const Logic::IState* state)
    const Resource::ICollection* resourceCollection = state->GetResourceCollection();
    const Resource::IBinary* myXmlFile = resourceCollection->GetBinary("Main:MyXmlFile");

	const ConstData& myXmlFileDataObject = myXmlFile->GetData();
	const UInt8* data = myXmlFileDataObject.GetData();
	UInt32 byteSize = myXmlFileDataObject.GetByteSize();

	// Do something useful...

    return true;
Thank you!!!

Thats exactly what I want/need!