XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Sun Nov 19, 2017 8:55 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Parsing XML files in Noesis
PostPosted: Sat Jun 18, 2016 2:59 am 
Offline
n00b

Joined: Sun Oct 05, 2014 12:08 am
Posts: 12
Has thanked: 22 times
Have thanks: 2 times

There's certain data for the models I am currently working on that is stored in XML files. I am using one of Python's provided XML parsers to handle them like this:
Code:
import xml.etree.ElementTree as etree

#a few lines later:
tree = etree.parse(xmlFilePath)
root = tree.getroot()


However, the code above causes Noesis to stop running the script, saying:
Code:
Traceback (most recent call last):
  File "C:\noesis\plugins\python\core321.zip\xml\etree\ElementTree.py", line 1488, in __init__
  File "C:\noesis\plugins\python\core321.zip\xml\parsers\expat.py", line 6, in <module>
ImportError: No module named pyexpat


Now, to the best of my knowledge, Noesis includes the core libraries for parsing XML, so I am unsure why it's failing. I would really wish to avoid reinventing the wheel by parsing the XML files myself. Does anyone know what would be the best way to parse XML files inside Noesis scripts?

I'm using the latest version of Noesis (v4.177)

You can make the ads go away by registering



Top
 Profile  
 
 Post subject: Re: Parsing XML files in Noesis
PostPosted: Sat Jun 18, 2016 6:25 am 
Offline
Moderator
User avatar

Joined: Sun May 18, 2008 3:01 pm
Posts: 2444
Has thanked: 56 times
Have thanks: 1190 times
from xml.dom.minidom import parseString


datasource = open(matFileName)
data = datasource.read()
dom = parseString(data)
soup = BeautifulSoup(datasource, 'xml')
tree = ET.parse('D:/Games/Data/materials.xml')
print(tree.getroot())

datasource.close()

you can try this.


Top
 Profile  
 
 Post subject: Re: Parsing XML files in Noesis
PostPosted: Sun Jun 19, 2016 6:07 am 
Offline
n00b

Joined: Sun Oct 05, 2014 12:08 am
Posts: 12
Has thanked: 22 times
Have thanks: 2 times
Thank you for your suggestions. Unfortunately I had no luck in getting them to work. Noesis keeps complaining about some missing reference in core321.zip like pyexpat. I'm thinking this might be because these missing Python libraries aren't included with the default Noesis distribution?

Reading the beginning of __NPReadMe.txt makes me think this is exactly what is happening:
Quote:
A trimmed down core 3.2.1 Python implementation is included. No modules (ctypes, sockets, etc.) are included - if you want support for them, you have to create a folder called "DLLs" under the Noesis folder and put them in it. DLLs not compiled for Python 3.2.1 may or may not work.
So I guess I will have to look around the web to download the missing modules. It's a shame if it must be done this way because this means that, unless I write my own XML parser in my script and reinvent the wheel, my script will need to include these extra DLLs to work. I'm hoping I'm wrong, is there really no built-in XML parser for Noesis?



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group