Dom Document Object Model aciliminin kisaltilmistir halidir ve HTML ya da XML dökümanlarini Obje ile calismaya yarar. Dom ayni zamanda bir W3C standartidir.  Örnek vericek olursak örnegin aspveasp.net sitesinde bir XML sayfasi oldugunu ve sizinde bunu okumaniz gerektigini düsünelim ;

 <?xml version=”1.0″ encoding=”Windows-1252″?>
 <articles>
 <article>
 <title><![CDATA[Tarih degerlerinde problem]]></title>
 <author><![CDATA[Mustafa Sahin]]></author>
 <url><![CDATA[http://www.aspveasp.net]]></url>
 <date><![CDATA[13.4.2008]]></date>
 <description><![CDATA[XML DOM DENEMESI.]]></description>
 </article>
 ….

 

Simdide Okuma Dom ile okuma islemine gelelim ,

 

<% @LANGUAGE = VBScript %>
<html>
<head>
<title>XML DOSYASINI OKUMA</title>
</head>
<body bgcolor=”#ffffff”>
<%
  Dim XMLDoc, rootNode, item
  Set XMLDoc = Server.CreateObject(”Microsoft.XMLDOM”)
  XMLDoc.async = False
  bLoadSuccess = XMLDoc.load(Server.MapPath(http://aspveasp.net/test.xml))
  If Not bLoadSuccess Then
  Response.Write “Could not load the XML document!”
  Else
Set rootNode = XMLDoc.documentElement
strOut = OutputNode(rootNode,1)
Response.Write “<PRE>” & vbCrlf
Response.Write strOut
Response.Write “</PRE>” & vbCrlf
  End If

  Function OutputNode(ByVal node, ByVal nDepth)
   strPadding = Space(nDepth)
   strOutput = strOutput & strPadding & “<” & node.nodeName & _
“>” & vbCrLf
   For Each item in node.childNodes
    If item.hasChildNodes() Then
      strOutPut = strOutput & OutputNode(item,nDepth+1)
    Else
      strOutput = strOutput & strPadding & “<” & item.nodeName & “>”
      strOutput = strOutput & item.Text
      strOutput = strOutput & “</” & item.nodename & “>” & vbCrLf
    End If
   Next
   strOutput = strOutput & strPadding & “</” & node.nodeName & _
“>” & vbCrLf
  OutputNode = strOutput
  End Function
%>
</body>
</html>

 </articles>

Posted in Xml ve Asp |

Mesajinizi / Yorumunuzu Yazin

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Kategoriler

Arsivler

Baglantilar

Site ici Arama

Meta: