* 각 링크를 새창(new Window)으로 띄우기 : Shift 누르고 왼쪽 클릭(Left Click)

Ssemi Laboratory 위치로그  |  태그  |  방명록 | 관리자
XML Dom Object - IE, Firefox Supported
Script/Javascript | 2009/01/21 16:02


See the table below for the differences.

IE Supported Code

Firefox Supported Code
Creating XML DOM object Creating XML DOM object
xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc  = document.implementation.createDocument("","doc",null);
Make sure before loading the XML file you use the following lines of code It is the same for Firefox
xmlDoc.async = false;xmlDoc.preserveWhiteSpace=true; xmlDoc.async = false;xmlDoc.preserveWhiteSpace=true;
Loading an XML file Loading an XML file
xmlDoc .load("XML Path"); xmlDoc.onload=function (){};xmlDoc .load("XML Path");
  Here Firefox does not support loading of XML directly. So we should use a dummy function and then load XML.
Selecting Single Node in an XML with conditions Selecting Single Node in an XML
xmlNode=xmlDoc.selectSingleNode("//Path[@Attribute='condition']/remaining path"); selectSingleNode is not supported in Firefox. We can use XML Path to do our job as given below.
  function SelectSingleNode(xmlDoc, elementPath){   if (document.implementation && document.implementation.createDocument)      {         var nodes=document.evaluate(elementPath, xmlDoc, null, XPathResult.ANY_TYPE, null);var results=nodes.iterateNext();return results;       }    }
  To the above function we need to pass XML and the Element path like "//Path[@Attribute='condition']/remaining path" and access it as below
  xmlNode=SelectSingleNode(xmlDoc ,"//Path[@Attribute='condition']/remaining path");
For getting value of particular Attribute For getting value of particular Attribute
xmlNode.getAttribute("Attribute Name");     Here we can use the code given below
  xmlNode.attributes["Attribute Name"].value;          
To access the Text of the Single Node selected To access the Text of the Single Node selected
xmlNode.text; xmlNode.childNodes[0].nodeValue;
Selecting Nodes list based on condition Selecting Nodes list based on condition
xmlNodes= xmlDoc.selectNodes(“Node name Path [@attribute=’condition’]”) For ex: var xmlNodes = xmlDoc.selectNodes("//xNode[@xid='test']"); xmlNodes=xmlDoc.getElementsByTagName[“Node name Path”];For ex: var xmlNodes = xmlDoc.getElementsByTagName[“xNode”];
Iterating through the Nodes List and selecting value of a particular Attribute Iterating through the Nodes List and selecting value of a particular Attribute
for(var n=0;  n< xmlNodes.length; n++){var xid= xmlNodes (n).getAttribute("xid");} xmlNodes contains only the Nodes which has the Attribute xid and which has value ‘test’. If the Attribute value = ‘test’, then we are iterating through that Nodes only and retrieving the value of xid. Here xmlNodes  contains all the list of Nodes which are having the Node Name “xNode”. for(var n=0;  n< xmlNodes.length; n++){  // For getting all the Attributes of the Node selected var getXmlAttributes = xmlDoc.getElementsByTagName("Node name ")[n].attributes; // For selecting Attribute value based on condition, we should first get the Attributes List which contains the Attribute we need as below. var selectXmlAttribute = getXmlAttributes.getNamedItem("xid").value; // For retrieving the value of the Attribute based on Condition. if (selectXmlAttribute =="test") {   var xid= getXmlAttributes.getNamedItem("xid").value;}  
IE supports both () and [] braces while using document object Firefox supports only [] braces while using document object.
Ex: document.forms(0); or document.forms[0]; Ex: or document.forms[0];
Use document.getElementById[“”] instead of document.allBoth are supported in IE  document.all is IE specific  
In script tag never forget to mention type=”text/javascript”, as now a days all browsers implicitly know and support Java Script For ex: <script language =”javascript” type = ”text/javascript”></script>  
Don’t close the script tag like <script language =”javascript” type = ”text/javascript”/> as some browsers like IE loads the first script, and then continues to look for a closing </script> tag. Use:<script language =”javascript” type = ”text/javascript”></script> 

I followed the above standards of Browser and solved it..

이올린에 북마크하기(0) 이올린에 추천하기(0)

태그 : , , , , ,

아이디 :
비밀번호 :
홈페이지 :
  비밀글로 등록
내용 :
 



[PREV] [1][2][3][4][5] ... [18] [NEXT]
BLOG main image
ALL Tip & Tech
분류 전체보기 (18)
Publish (3)
Script (7)
Program (7)
Database (1)
Adobe (0)
XML Dom Object - IE, Firefox Supported
자바스크립트 디버깅을 해보자
ASP 페이지를 엑셀로 변환하기- ASP Conv..
웹 상의 이미지를 쉽게 서버에 올려주자..
자신의 게시판에 새 글이 올라오면 알려..
IIS서버 로그 관리를 스크립트로 간편하게
API 레퍼런스의 천국 GotAPI.com
캄쏴~~~ 좋은 자료 잘쓰겠습니다.
2008 - tabler
쿼리자체가 SQL 2000기준이에요 SQL2005..
2008 - Ssemi™
좋은 자료 감사합니다. 윈도우 2003 에..
2007 - Good~~~
좋은 자료 감사합니다.
2007 - 달래
정말 좋은 자료 감사합니다.
2007 - powerxml
괜찬은 프로그램인듯하네요
2007 - 천지월영
저도 이리저리 테스트해보고 사용해봤는..
2007 - idea
너무너무너무너무너무 좋네요 이런 아이..
2007 - 버리
맞아요!! 티스토리 플러그인으로 만들면..
2007 - 아인리스☆
요거를 테터 블로그의 플러그인으로 만드..
2007 - 용희
Ssemi's Episode
rss
 
 

JavaScript asp Firefox Library MSSQL framework Prototype Coding Stored Procedure Tracker Script.Aculo.us Definition 디버깅 Control Highlight Rollover DOM Menu Document Client Infomation Prototype Window Class Debugging script debugger Firebug Convert Debug 게시물 Develop XUL