-
xml = minidom.Document()
-
-
# Creates user element
-
userElem = xml.createElement("user")
-
-
# Set attributes to user element
-
userElem.setAttribute("name", "Sergio Oliveira")
-
userElem.setAttribute("nickname", "seocam")
-
userElem.setAttribute("email", "seocam@seocam.net")
-
userElem.setAttribute("photo","seocam.png")
-
-
# Append user element in xml document
-
xml.appendChild(userElem)
-
-
fp = open("d://file.xml","w")
-
xml.writexml(fp, " ", "", "\n", "UTF-8")
-
i get this result when i open the xml[internet explorer]
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
XML document must have a top level element. Error processing resource 'file:///D:/file.xml'.
thanks for kind of help in advance :D
4 1585
How about pasting the resulting xml file?
-kudos -
xml = minidom.Document()
-
-
# Creates user element
-
userElem = xml.createElement("user")
-
-
# Set attributes to user element
-
userElem.setAttribute("name", "Sergio Oliveira")
-
userElem.setAttribute("nickname", "seocam")
-
userElem.setAttribute("email", "seocam@seocam.net")
-
userElem.setAttribute("photo","seocam.png")
-
-
# Append user element in xml document
-
xml.appendChild(userElem)
-
-
fp = open("d://file.xml","w")
-
xml.writexml(fp, " ", "", "\n", "UTF-8")
-
i get this result when i open the xml[internet explorer]
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
XML document must have a top level element. Error processing resource 'file:///D:/file.xml'.
thanks for kind of help in advance :D
i am getting an empty file :S
Are you importing the minidom library? -
from xml.dom import minidom
-
-
xml = minidom.Document()
-
-
# Creates user element
-
userElem = xml.createElement("user")
-
-
# Set attributes to user element
-
userElem.setAttribute("name", "Sergio Oliveira")
-
userElem.setAttribute("nickname", "seocam")
-
userElem.setAttribute("email", "seocam@seocam.net")
-
userElem.setAttribute("photo","seocam.png")
-
-
# Append user element in xml document
-
xml.appendChild(userElem)
-
-
fp = open("d://file.xml","w")
-
xml.writexml(fp, " ", "", "\n", "UTF-8")
-
i get this result when i open the xml[internet explorer]
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
XML document must have a top level element. Error processing resource 'file:///D:/file.xml'.
thanks for kind of help in advance :D
yea i already have that imported!
never mind i wrote another code from a whle different approach, thnx 4 the help anyway m8 ;)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chris Geerdink |
last post by:
combo with PHP. what is wrong with the Javascript?
else
{
include("mysql.php");
$query1 = mysql_query("INSERT INTO gbook (naam, email, text) VALUES
('".$_POST."', '".$_POST."',...
|
by: asdf |
last post by:
Hello!
Can someone tell me whats wrong with this piece of code:
Option Compare Database
Option Explicit
Sub retrieve()
Dim rst As ADODB.Recordset
Dim i As Integer
|
by: mahsa |
last post by:
Hi do you know whats wrong with this code?
<asp:HyperLink id="HLink_Help" runat="server" NavigateUrl='<%# "javascript:window.open('comments.aspx?id=1,width=500,height=600, scrollBars=yes');"...
|
by: blah |
last post by:
Hello everyone, Ive been trying to get my application to "click" on a
button in another application using SendMessage, Ive gotten this far
but Im not sure whats wrong with this code, here is the...
|
by: Mike Barnard |
last post by:
It's a simple test... VERY SIMPLE. But...
In an external stlyesheet some attributes don't show. With the same
styles cut and pasted to the test internally it works as expected.
Anyone tell...
|
by: Abubakar |
last post by:
Hi,
In my application, Some of my thread gets stuck somewhere. The vs2k5
debugging "Thread" window shows that stuck thread and I can I dentify it. In
its Name column the following text is...
|
by: fcvcnet |
last post by:
Hi,
In swith statements, follow case is constant-expression, can it be a
range?
For example:
...
case ' 0 ' :
...
thanks.
|
by: islayer |
last post by:
can someone tell me what is wrong with the bold code? i am just learning perl. the program should create a perl file with a random name (5 letters, followed by a number), but the name is always just...
|
by: hiqu |
last post by:
This issue is driving me nuts and not able to figure out whats wrong.
I've this code in my firefox extension. Firefox always hangs and
reports the script is busy.
if I introduce a break...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |