Official Murl Engine Forum
Location/Reading custom xml files - Printable Version

+- Official Murl Engine Forum (https://murlengine.com/forum)
+-- Forum: Murl Engine (https://murlengine.com/forum/forumdisplay.php?fid=5)
+--- Forum: General (https://murlengine.com/forum/forumdisplay.php?fid=8)
+--- Thread: Location/Reading custom xml files (/showthread.php?tid=15)



Location/Reading custom xml files - Arami - 05 May 2013

Hi,

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?

thx

Andreas


RE: Location/Reading custom xml files - dizzy - 06 May 2013

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"/>
</Package>

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;
}



RE: Location/Reading custom xml files - Arami - 06 May 2013

Thank you!!!

Thats exactly what I want/need!

Andreas