473,378 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ElementTree xmlns:xsi question

Hi there,

I'm generating an XML script using ElementTree which has the following
attributes in the root element:

<CANmessages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="code/can.xsd">

My python script I have written is:

root = Element("CANmessages",
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance",
xsi:noNamespaceSchemaLocation="code/can.xsd")

Obviously there is a syntax error inregard to the colons in the
attribute names. I have to have the xsi attributes in there otherwise
the XML won't work correctly. What can I do to make the code correct
and the output being 100% correct as well. Any help would be greatly
appreciated.

Craig

Nov 28 '06 #1
1 7693
Craig wrote:
I'm generating an XML script using ElementTree which has the following
attributes in the root element:

<CANmessages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="code/can.xsd">
those are namespace declarations, and mean that tags prefixed by "xsi"
really belongs to the http://www.w3.org/2001/XMLSchema-instance name-
space.
My python script I have written is:

root = Element("CANmessages",
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance",
xsi:noNamespaceSchemaLocation="code/can.xsd")
try:

NS_XSI = "{http://www.w3.org/2001/XMLSchema-instance}"

root = Element("CANmessages")
root.set(NS_XSI + "noNamespaceSchemaLocation", "code/can.xsd")

also see:

http://effbot.org/zone/element.htm#xml-namespaces

</F>

Nov 29 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: dayzman | last post by:
Hi, Is anyone here familiar with ElementTree by effbot? With <html><body>hello</body></html> how is "hello" stored in the element tree? Which node is it under? Similarly, with: foo <a href =...
3
by: Matthew Thorley | last post by:
Why does ElementTree.parse convert my xsi to an xmlns? When I do this from elementtree import ElementTree # Sample xml mgac =""" <mgac xmlns="http://www.chpc.utah.edu/~baites/mgacML"...
0
by: Lindy | last post by:
I'm using VB .Net and am new to XML. I need to create an XML file with the following lines: <?xml version="1.0" encoding="UTF-8" ?> - <HC_DATA...
0
by: Paul | last post by:
I have xml returning from a webservice which look like so... <CiscoIPPhoneMenu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">...
0
by: Ewan Fairweather | last post by:
Hi, I'm generating the below XML in c# for an asp.net application When i've generated this XML the <LaboratoryDetails xmlns=""> element has a blank xmlns set. How do i either a) remove this...
3
by: Keith Patrick | last post by:
I'm doing some document merging where I want to bring in an XmlDocument and import its document element into another document deeper in its tree. However, when serializing my underlying objects,...
7
by: Tim Arnold | last post by:
Hi, I'm using elementtree and elementtidy to work with some HTML files. For some of these files I need to enclose the body content in a new div tag, like this: <body> <div class="remapped">...
2
by: Zvi | last post by:
Hi All, Can someone tell me why id the following not working? I have a soap response envelope, for test purpose it's just a string and I create ElementTree from it. Then I try to find Response...
2
by: killy971 | last post by:
I am using java to validate an XML file with a DTD, without having the DVD declaration inside the original file, by setting the doctype dynamically to a transformer like this : ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.