473,383 Members | 1,929 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.

dynamically generating XML prob

Hi,
I am generating an XML document dynamically using DOM.
I am creating an element using IXMLDOMDocument::createElement() and
then calling IXMLDOMElement::appendChild() for the parent element. For
attributes, I use IXMLDOMDocument2::createAttribute() and then
IXMLDOMElement::setAttributeNode().

My problem is that for each of the elements, an additional "xmlns"
attribute is added with no value (xmlns=""). How can I avoid getting
this extra attribute from being inserted? Note that I am not putting a
prefix for the element names.
--- Sample XML generated-----------------
<MyRoot xmlns="http://www.xyz.com/abc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xyz.com/abc abc.xsd">
<MyElement1 xmlns="" attrib1="v1"/>
..
..
</MyRoot>
-----------------------------------------
Thanks in advance.

Jul 20 '05 #1
1 1960


na***********@yahoo.com wrote:

I am generating an XML document dynamically using DOM.
I am creating an element using IXMLDOMDocument::createElement() and
then calling IXMLDOMElement::appendChild() for the parent element. For
attributes, I use IXMLDOMDocument2::createAttribute() and then
IXMLDOMElement::setAttributeNode().

My problem is that for each of the elements, an additional "xmlns"
attribute is added with no value (xmlns=""). How can I avoid getting
this extra attribute from being inserted?


Sounds as if you are using MSXML, with MSXML you should use
createNode(1, 'element-name', 'namespaceURI')
if you want to create elements in a namespace. If you use
createElement('element-name')
then the element is created in the null namespace and thus when the
document is serialized the
<element-name xmlns="">
needs to be added to properly serialize the document.

So you want (JScript syntax)
var rootElement = xmlDocument.createNode(
1,
'MyRoot',
'http://www.xyz.com/abc'
);
var myElement = xmlDocument.createNode(
1,
'MyElement1',
'http://www.xyz.com/abc'
);

If you are not using MSXML but a W3C DOM Level 2 compliant
implementation then you need to use
var rootElement = xmlDocument.createElementNS(
'http://www.xyz.com/abc',
'MyRoot'
);
var myElement = xmlDocument.createElementNS(
'http://www.xyz.com/abc',
'MyElement1'
);

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2

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

Similar topics

13
by: Tim Henderson | last post by:
Hi I want to dynamically generate a graph in python that would be displayable on a web page. What would be the best way to do this? The reason I want to do this, is because I am making a program...
2
by: Scott | last post by:
hi friend's, i m new in both things php and in this group. but i have some basic knowledge of php and DOM in php. here is my problem, i have one textfield for add a new main node (not main like:...
0
by: Raghavendra | last post by:
hi, we r using forms authetication. problem :- i am using the below code to generate excel report but since we r using forms authetication.. after generating excel report the browser directs...
4
by: Terry Holland | last post by:
I am a vb6 programmer just moving over to vb.net. I have an form onto which I have dynamically added a number of panels. I have dynamically added a label and three RadioButtons to each of these...
27
by: ted benedict | last post by:
hi everybody, i hope this is the right place to discuss this weird behaviour. i am getting dynamically generated text or xml from the server side using xmlhttprequest. if the server side data is...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
0
by: krish | last post by:
hi, I am dynamically generating Imagebutton (say 5 imagebutton, in loop) . for each imagebutton url , i am dynamically generating image and assigining to it. every thing is ok upto this...
0
by: Aswanth | last post by:
I'm Working with Asp.Net with C#.. & I'm Generating Reports in SSRS-2005.. Till Now I'm Generating Reports in SSRS-2005 with Stored Procedure.. in Which I'm Generating Reports for One...
9
by: Dahak | last post by:
I'm trying to generate dynamic functions to use as separate callbacks for an AJAX API call. The API doesn't seem to allow for the inclusion of any parameters in the callback, so I can't...
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
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...
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.