Problem mit XML und appendChild
Von: Dirk Herwig (dherwig1961@googlemail.com) [Profil]
Datum: 08.10.2009 21:47
Message-ID: <halfm5$1o1$00$1@news.t-online.com>
Newsgroup: de.comp.lang.javascript
Datum: 08.10.2009 21:47
Message-ID: <halfm5$1o1$00$1@news.t-online.com>
Newsgroup: de.comp.lang.javascript
Hallo,
ich lade von einem Webservice ein XML-Dokument und speichere dieses lokal
_setLayout: function(val) {
// XML Dokument wird geladen und gespeichert in _xmllayout
this._xmllayout = val;
}
Das XML Dokument liegt folgendermaßen vor:
<?xml version="1.0" encoding="utf-8" ?>
<controls id="8" layoutname="Test" art="x"
width="1360" height="768"
bgcolor="#950B2D" bgimage="IMG_3372.JPG"
showimage="true">
<control id="1" containername="mitte" left="100"
top="10" width="500"
height="400" bgcolor="#FF00FF" zindex="10" />
</controls>
Ich möchte nun clientseitig das XML Dokument bearbeiten, bevor ich es wieder
zum Server schicke.
Ich habe versucht, einen neuen Knoten (control) zu erstellen und diesen dann
wieder an das Orginaldokument (controls) anzuhängen, jedoch ohne Erfolg.
_addContainerNode: function("controls", _name, _nid, _left, _top, _width,
_height, _bgcolor) {
tempdiv = document.createElement("control");
tempdivid = document.createAttribute("id");
tempdiv.setAttributeNode(tempdivid);
tempdiv.id = _nid;
tempdivname = document.createAttribute("containername");
tempdiv.setAttributeNode(tempdivname);
tempdiv.containername = _name;
tempdivleft = document.createAttribute("left");
tempdiv.setAttributeNode(tempdivleft);
tempdiv.left = _left;
tempdivtop = document.createAttribute("top");
tempdiv.setAttributeNode(tempdivtop);
tempdiv.top = _top;
tempdivwidth = document.createAttribute("width");
tempdiv.setAttributeNode(tempdivwidth);
tempdiv.width = _width;
tempdivheight = document.createAttribute("height");
tempdiv.setAttributeNode(tempdivheight);
tempdiv.height = _height;
tempdivbgcolor = document.createAttribute("bgcolor");
tempdiv.setAttributeNode(tempdivbgcolor);
tempdiv.bgcolor = _bgcolor;
var nodes = this._xmllayout.getElementsByTagName(_pattern)[0];
nodes.appendChild(tempdiv);
alert("_xmllayout: " + typeof (this._xmllayout) + "<br />" +
"tempdiv: "
+ typeof (tempdiv)); // Beides Object
}
Ich erhalte im IE (7) folgende Fehlermeldung an der Stelle mit dem
appendChild:
"Laufzeitfehler in Microsoft JScript: Typen unverträglich".
Könnt ihr mir hier weiterhelfen?
Gruss
Dirk
[ Auf dieses Posting antworten ]Antworten
- Thomas 'PointedEars' Lahn (09.10.2009 00:23)
- Dirk Herwig (09.10.2009 01:02)
- Thomas 'PointedEars' Lahn (09.10.2009 02:52)
- Holger Jeromin (09.10.2009 08:34)
- Thomas 'PointedEars' Lahn (09.10.2009 11:01)
- Dirk Herwig (09.10.2009 10:24)
- Thomas 'PointedEars' Lahn (09.10.2009 11:03)
