IEとFirefoxブラウザに対応してXML(英)を操作します。


本論文は抜き書きであるhttp://www.w3schools.com
 
To read and up date-create and manipulate-an XML document,you will need an XML parser.
Microsoft's XML Paser
Microsoft's XML parser is COM component that commes with Internet Explorer 5 and higher.Onece you have installed Internet Explorer,the parser is available to scripts.
マイクロソフトのXML解像器はIE 5またはより高いバージョンに付属のCOMコンポーネントです。IEをインストールすると、この解像度はシナリオに使用できます。
Microsoft's XML parser supports all the necessary functions to trverse the node tree、access the nodes and the the the ir atribute values、insert and delete nodes、and convert the node trback to XML.
マイクロソフトのXML解析器は、変換ノードツリー、アクセスノードおよびそれらの属性、ノードの挿入と削除、およびノードツリーをXMLに変換する機能をすべてサポートしています。
The follwing table lists the most commonly used node types supported by Microsoft's XML parser:
下表には、マイクロソフトXML解析器で最もよく使われているノードの種類が記載されています。
Node Type
Example
Processing instruction
<?xml version=「1.0」
Element
<drink type=「ber」カールバーグ
アタッチブ
type=「beer」
Text
カールバーグ
MSXML Paser 2.5 is the XML parser that is shipped with Windows 2000 and IE 5.5.
MSXML解像器2.5版はWINDOW 2000とIE 5.5に実装されています。
MSXML Paser 3.0 is the XML parser that is shipped with IE 6.0 and Windows XP.
MSXML解像器3.0版はWINDOWS XPとIE 6.0に実装されています。
The MSXML 3.0 parser feature s:
  • JavaScript、VB Script、Perl、VB、Java、C+、etc.support
  • Compplete XML support
  • フルDOM and Namespace support
  • DTV and validation
  • Compplete XSLT and XPS support
  • SAX 2 support
  • Server-safe HTTP
  • MSXML 3.0版の特徴
  • はJavaScript、VB Script、Perl、VB、Java、C++などの
  • をサポートします。
  • XML
  • 完全サポート
  • DOMとNamespace
  • を完全にサポートします。
  • は、DMDおよび検証をサポートする
  • XSLTとXPS
  • を完全にサポートします。
  • サポートSAX 2
  • HTTPサーバ端のセキュリティ(Server-safe HTTP)
  • をサポートします。
    To create an instance of Microsoft's XML parser with JavaScript、use the follwing code:
    JavaScriptについては、次のコードを使ってマイクロソフトXML解析器の例を作成します。
     

    To create an instance of Microsoft's XML parser with VBScript, use the following code:

    对于VBScript, 使用下面的代码创建一个微软XML解析器实例

    set xmlDoc=CreateObject("Microsoft.XMLDOM")
    To create an instance of Microsoft's XML parser in an ASP page(using VBScript)、use the follwing code:
    サーバー側VBScriptに対して、下記のコードを使ってマイクロソフトXML解像器の例を作成します。
    set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
    The follwing code loads an existing XML document(「note.xml」)into Microsoft's XML parser:
    次のコードはXMLドキュメント「note.xml」をマイクロソフトXML解析器に読み込みます。
    
    
    ...
    ...
    ...
    
    The first line of the script above creates an instance of the Microsoft XML parser.The third line Tels the parser to load an XML document caled.The second line offic the funce
    XML Paser in Mozila Browsers
    Plain XML documents are displayed in a tree-like structure in Mozila(just like IE)
    Mozilla also supports parsing of XML data using JavaScript.The parsed data can be displayed as HTML.
    To create an instance of the XML parser with JavaScript in Mozara browsers、use the follwing code:
     

    The first parameter, ns, defines the namespace used for the XML document. The second parameter, root, is the XML root element in the XML file. The third parameter, null, is always null because it is not implemented yet.

    The following code loads an existing XML document ("note.xml") into Mozillas' XML parser:

    
    
    ...
    ...
    ...
    
    The first line of the script above creates an instance of the XML parser.The second line Tels the parser to load an XML document caled“not.xml”.
    Loading an XML File-A Cross browser Example
    The follwing example is a cross browser example that loads an existing XML document(「note.xml」)into the XML parser:
    
    
    
    var xmlDoc
    function loadXML()
    {
    //load xml file
    // code for IE
    if (window.ActiveXObject)
      {
      xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
      xmlDoc.async=false;
      xmlDoc.("note.xml");
      getmessage()
      }
    // code for Mozilla, etc.
    else if (document.implementation &&
    document.implementation.createDocument)
      {
      xmlDoc= document.implementation.createDocument("","",null);
      xmlDoc.("note.xml");
      xmlDoc.οnlοad=getmessage
      }
    else
      {
      alert('Your browser cannot handle this script');
      }
    }</pre> <pre>function getmessage()
    {
    document.getElementById("to").innerHTML=
    xmlDoc.getElementsByTagName("to")[0].firstChild.nodeValue
    document.getElementById("from").innerHTML=
    xmlDoc.getElementsByTagName("from")[0].firstChild.nodeValue
    document.getElementById("message").innerHTML=
    xmlDoc.getElementsByTagName("body")[0].firstChild.nodeValue
    }
    
    
    Try it yourself
     
     
    Loading XML Text Into the Parsser
    Internet Explorer supports two ways of loading XML into a document object:the load()method and the loadXML()method.The load()method loads and the loadXML
    The follwing code loads a text string into Microsoft's XML parser:
    
    

    W3Schools Internal Note

    To:
    From:


    Message:
    var txt=""
    txt=txt+"ToveJani"
    txt=txt+"Reminder"
    txt=txt+"Don't forget me this weekend!"
    txt=txt+""
    If you have Internet Explorer,you can try it yourself.