473,737 Members | 7,206 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding nodes to custom tags

I'm building a cross-browser XML dataisland.
This code works perfectly in mozilla, but i have problems with explorer.

it tells me that:
"diXML.getEleme ntsByTagName(.. ).0 is null or not an object"

if i change my custom xml dataisland using <xml id="dataisland" ></xml>
instead of the <div id="dataisland " ...> it shows a "type mismatch" error.

I have no problem accesing to the <di> tags inside the <table
id="dataisland_ table">, so i can't see why i can't access them on the <div>.
Here is the code:


diFirstNode="di ";
diItemNode="tes t";

function diXMLEdit (theForm,dI) {

diXML=document. getElementById( dI);
diForm=document .forms[dI+'_form'];
xmlElem=documen t.createElement (diItemNode);

for (i=0;i<theForm. elements.length ;i++) {
if (theForm.elemen ts[i].type!="button" ) {
if (diForm.dirow.v alue=="") {
xmlNode=documen t.createElement (theForm.elemen ts[i].name);
xmlNode.innerHT ML=theForm.elem ents[i].value;
xmlElem.appendC hild(xmlNode);
} else {


if (diForm.dirow.v alue=="") {
diXML.getElemen tsByTagName(diF irstNode)[0].appendChild(xm lElem);
} else {

//diPopulate(theF orm,dI);
<form name="dataislan d_form">
<input type="hidden" name="dirow">

<div id="dataisland " style="display: none">

<table id="dataisland_ table">
<tr id="dataisland_ header">
<tr id="dataisland_ schema" style="display: none">
<td><di field="aa"></di></td>
<td><di field="bb"></di></td>
<td><di field="cc"></di></td>

<form name="myform">

<br><input type="text" name="aa">
<br><input type="text" name="bb">
<br><input type="text" name="cc">
<br><input type="button" value="go!"
onClick="diXMLE dit(document.my form,'dataislan d')">

Jul 23 '05 #1
2 3441
> diXML.getElemen tsByTagName(diF irstNode)[0].appendChild(xm lElem);

As far as I have tried it seems that there is no possibility to directly
access the <di> tag in "dataisland ".
A work around of that would be adding the following lines of code BEFORE the
line shown above:

diXML.removeChi ld(diXML.firstC hild);
var newDI = document.create Element("di");
diXML.appendChi ld(newDI);

This means: First remove the first child element <di> in "dataisland ", then
re-add it with the appendChild method.
After this your appendChild of "test" won't cause any javascript error.

Hope this helps you.

Nice greetings from
Jul 23 '05 #2
En/na Thomas Hoheneder ha escrit:
diXML.removeChi ld(diXML.firstC hild);
var newDI = document.create Element("di");
diXML.appendChi ld(newDI);

This means: First remove the first child element <di> in "dataisland ", then
re-add it with the appendChild method.
After this your appendChild of "test" won't cause any javascript error.

i've tried that but when i try to appendChild to 'di', it continues
failing me.

i've tried:
diXML.firstChil d.appendChild(x mlElem);
diXML.getElemen tsByTagName(diF irstNode)[0].appendChild(xm lElem);

and none of them work.
BTW, i've got another approach which is working. It uses separate code
for moz and ie (though i never liked doing this kind of code).

if (!document.all) {
diXML=document. getElementById( dI);
xmlElem=documen t.createElement (diItemNode);
} else {
diXML=document. all(dI).XMLDocu ment;
xmlElem=diXML.c reateElement(di ItemNode);

thanks for the help.
Jul 23 '05 #3

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

Similar topics

by: alanrn | last post by:
I am using a TreeView to display the hierarchy of a strongly-typed collection (inherited from CollectionBase). The order of the nodes in the TreeView is strictly tied to the order in which they appear in the underlying collection. However, the user must be able to reorder certain items in the collection--and, hence, the TreeView. I have created a context-sensitive menu that allows the user to move an item in the collection either up or...
by: Todd | last post by:
I have the following code that inserts a new element and its attributes into an xml file. The problem is the syntax of the inserted row. here is my code: 'Create an XmlDataDocument. Dim doc As XmlDataDocument = New XmlDataDocument 'Load the schema. doc.DataSet.ReadXmlSchema("c:\animal.xsd") Dim dtAnimals As DataTable = doc.DataSet.Tables.Item("animal") 'Load the XML data. Dim reader As XmlTextReader = New XmlTextReader("c:\animal.xml")
by: Paul J Lay | last post by:
I am trying to find nodes in an xml document using the XmlDocument class and having some problems. Everything seems to work OK when there are no encoded characters (< = &lt;) but when I try to navigate a document in which the outer nodes are not encoded but the nested nodes are encoded, I can't find any of the encoded nodes using the XmlDocument selectNodes method. Is there a simple way to handle this situation? Please advise. Thanks for...
by: fix | last post by:
Hi, I have an XML document and I need to add some attributes to an element. I use the XMLDocument object to load the xml file, and I can get the element I need to add attributes to in an XMLNode. The problem is, it seems that I cannot create a new XmlAttribute, it has no constructor. Does anyone have any idea how I can do this? I would appreciate your help. Thanks. fix.
by: Brian Henry | last post by:
If i already have a tree view created, and want to add another new node to it, how would i do so? Is there a way to throught tags or anything? like i have this RootNode | +-- Child 1 +-- Child 2 and i want to add a child node to child 1 how would i refrence it and add a
by: Papajo | last post by:
  I'd like to know how to add break tags "<br>" inbetween entry's in an input form, an example is if the word "yada yada" was entered you would wind up with y<br>a<br>d<br>a<br> y<br>a<br>d<br>a I would like to able to add the break tags with a button onClick. I have no idea where to start, sorry. Any help is appreciated, Thanks Joe
by: gregmcmullinjr | last post by:
Hello, I am new to the concept of XSL and am looking for some assistance. Take the following XML document: <binder> <author>Greg</author> <notes> <time>11:45</time>
by: rohan_from_mars | last post by:
I have a windows service and am also using Enterprise Library June 2005 version. Now i have created Setup and Deployment Project which installs the service. but how do i add EL dlls- Common.dll, Logging.dll, Configuration.dll, Data.dll into setup project so that it is also installed automatically. It should perform what the 'Install Services.bat ' performs. I have created ProjectInstaller.cs file also
by: =?Utf-8?B?U2hhbmU=?= | last post by:
Hi all, Is it possible to add controls like buttons, textboxes etc to treeview nodes like this link: http://webui30.componentart.com/treeview/features/nesting_aspnetContent/WebForm1.aspx The nesting asp.net components example. ..........................or do I have to buy this component to do it. :-)
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.