473,575 Members | 3,347 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:

<script>

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);
}
</script>
<form name="dataislan d_form">
<input type="hidden" name="dirow">
</form>

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

<table id="dataisland_ table">
<tr id="dataisland_ header">
<th>aa</th>
<th>bb</th>
<th>cc</th>
</tr>
<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>
</tr>
</table>

<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')">

</form>
Jul 23 '05 #1
2 3434
> 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
Thomas
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

4
1285
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...
1
1400
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 =...
8
1573
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...
8
3239
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...
3
2464
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
3
1543
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
9
2094
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>
1
3589
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...
4
8101
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. :-)
0
7845
marktang
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...
0
7775
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7868
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...
0
8143
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3778
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...
0
3797
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1382
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1107
bsmnconsultancy
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...

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.