473,383 Members | 1,840 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,383 software developers and data experts.

whats wrong swith this code?

Expand|Select|Wrap|Line Numbers
  1. xml = minidom.Document()
  2.  
  3. # Creates user element
  4. userElem = xml.createElement("user")
  5.  
  6. # Set attributes to user element
  7. userElem.setAttribute("name", "Sergio Oliveira")
  8. userElem.setAttribute("nickname", "seocam")
  9. userElem.setAttribute("email", "seocam@seocam.net")
  10. userElem.setAttribute("photo","seocam.png")
  11.  
  12. # Append user element in xml document
  13. xml.appendChild(userElem)
  14.  
  15. fp = open("d://file.xml","w")
  16. xml.writexml(fp, "    ", "", "\n", "UTF-8")
  17.  


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
Dec 30 '07 #1
4 1585
kudos
127 Expert 100+
How about pasting the resulting xml file?

-kudos

Expand|Select|Wrap|Line Numbers
  1. xml = minidom.Document()
  2.  
  3. # Creates user element
  4. userElem = xml.createElement("user")
  5.  
  6. # Set attributes to user element
  7. userElem.setAttribute("name", "Sergio Oliveira")
  8. userElem.setAttribute("nickname", "seocam")
  9. userElem.setAttribute("email", "seocam@seocam.net")
  10. userElem.setAttribute("photo","seocam.png")
  11.  
  12. # Append user element in xml document
  13. xml.appendChild(userElem)
  14.  
  15. fp = open("d://file.xml","w")
  16. xml.writexml(fp, "    ", "", "\n", "UTF-8")
  17.  


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
Dec 31 '07 #2
i am getting an empty file :S
Dec 31 '07 #3
seocam
1
Are you importing the minidom library?

Expand|Select|Wrap|Line Numbers
  1. from xml.dom import minidom
  2.  
Expand|Select|Wrap|Line Numbers
  1. xml = minidom.Document()
  2.  
  3. # Creates user element
  4. userElem = xml.createElement("user")
  5.  
  6. # Set attributes to user element
  7. userElem.setAttribute("name", "Sergio Oliveira")
  8. userElem.setAttribute("nickname", "seocam")
  9. userElem.setAttribute("email", "seocam@seocam.net")
  10. userElem.setAttribute("photo","seocam.png")
  11.  
  12. # Append user element in xml document
  13. xml.appendChild(userElem)
  14.  
  15. fp = open("d://file.xml","w")
  16. xml.writexml(fp, "    ", "", "\n", "UTF-8")
  17.  


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
Jan 2 '08 #4
yea i already have that imported!

never mind i wrote another code from a whle different approach, thnx 4 the help anyway m8 ;)
Jan 2 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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."',...
4
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
3
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');"...
4
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...
7
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...
1
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...
5
by: fcvcnet | last post by:
Hi, In swith statements, follow case is constant-expression, can it be a range? For example: ... case ' 0 ' : ... thanks.
5
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...
5
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...
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
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...
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: 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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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?
0
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...

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.