python client, issue with adding xml files
Hi,
The python samples pass an simple xml string to create or add:
session = BaseXClient.Session('localhost', 1984, 'admin', 'admin')
session.create("database", "<x>Hello World!</x>")
but how can I request the server to open a file or a directory?
Basically
session.create("database", "c:/tmp/myfile.xml")
returns the following error message: "database.xml" (Line 1): No text allowed before root element.
Thanks in advance for tips
Laurent Le Meur
Hi Laurent,
if your client and server is placed on the same machine, you may use
session.execute("create db /path/to/files")
Otherwise, you'll have to read the files via Python and pass them on via create/add.
Hope this helps, Christian
Quoted text · LE MEUR Laurent · 16 lines
> The python samples pass an simple xml string to create or add: > > session = BaseXClient.Session('localhost', 1984, 'admin', 'admin') > session.create("database", "<x>Hello World!</x>") > > but how can I request the server to open a file or a directory? > > Basically > > session.create("database", “c:/tmp/myfile.xml") > > returns the following error message: "database.xml" (Line 1): No text > allowed before root element. > > Thanks in advance for tips > Laurent Le Meur
Written for BaseX 7.3. BaseX may have changed since: please check the current documentation.