Loading Data Assets?

when I load from mf file it says don’t exist, but when I load it from disk, it works fine.

import xml.etree.ElementTree as ET
from panda3d.core import VirtualFileSystem
from panda3d.core import Multifile
from panda3d.core import Filename

mf = Multifile()

vfs = VirtualFileSystem.getGlobalPtr()
if vfs.mount(mf, ".", VirtualFileSystem.MFReadOnly):
  print 'mounted'

tree = ET.parse('data/test.xml')
root = tree.getroot()
data1 = root.find('data1').text
data2 = root.find('data2').text

ElementTree doesn’t use the VFS, but you can pass in a file-like object opened via direct.stdpy.file, which provides versions of Python’s built-in file operations that respect Panda’s Virtual File System:

from direct.stdpy.file import open

tree = ET.parse(open('data/test.xml', 'r'))

thanks for the help :slight_smile: