Artikel Terbaru

DOM Nodes

Xml DOM Nodes in Hindi

DOM Nodes
DOM के द्वारा XML document hierarchical tree structure के रूप में represent किया जाता है। इस tree structure को node tree कहा जाता है। Node tree में document की हर information को node के रूप में show किया जाता है।


DOM द्वारा create किया गया node tree structure पूरी तरह nodes द्वारा बना होता है। ऐसा भी कहा जा सकता है की DOM में सब कुछ node ही होता है। Elements, attributes, text आदि सम्पूर्ण data nodes के रूप में ही represent किया जाता है।



Types of XML DOM Nodes 

XML DOM द्वारा create की गयी nodes को उनके द्वारा present की जाने वाली information के आधार पर अलग अलग नामों से जाना जाता है। इनके बारे में निचे दिया जा रहा है। 

  • Document Node - Document Node पुरे document को represent करती है। यह node hierarchy में सबसे top पर होती है। इस node की child एक ही node होती है जो आपके XML document का root element होता है। 
  • Root Node - आपके document का root element root node द्वारा represent किया जाता है। 
  • Element Node - Root node के अंतर्गत आने वाले सभी elements element node के रूप में represent किये जाते है। 
  • Attribute Node - यदि किसी element में कोई attribute define किया गया है तो उसे attribute node के रूप में represent किया जाता है। Attributes किसी element के बारे में additional information provide करते है। XML elements के लिए भी attributes उसी प्रकार define किये जाते है जिस प्रकार HTML elements के define किये जाते है। 
  • Text Node - Elements द्वारा define किया गया text (Data) text node के रूप में present किया जाता है। 
  • Comment Node - यदि आपने XML document में comments define किये है तो वे comment node के रूप में show किये जाते है। 
  • CDATA Node - यदि document में CDATA section define किया गया है तो CDATA information CDATA node के रूप में show की जायेगी। 

Example of DOM Node Tree 

आइये DOM द्वारा create किये जाने वाले node tree को उदाहरण से समझने का प्रयास करते है। निचे एक XML document दिया जा रहा है जिसका नाम Employees.xml है। 

<?xml version="1.0" encoding="UTF-8"?>

<Employees Deparment="Technical">

<ajay Designation="Senior Programmer">

<age>29</age>

<salary>15000</salary>

</ajay>

<rahul Designation="Junior Programmer">

<age>25</age>

<salary>10000</salary>

</rahul>

</Employees>


ऊपर दी गयी Employees.xml file document node द्वारा represent की जायेगी। इस file में Employees root node है। Ajay और rahul दो मुख्य element nodes है। इन nodes की child nodes के रूप में age और salary elements होंगे।



Age और salary elements द्वारा hold किया गया data text nodes के रूप में represent होगा। Employes, ajay, rahul elements में define किये गए attributes attribute nodes के द्वारा represent किये जायेंगे।



इस document की information DOM द्वारा node tree के रूप इस प्रकार represent की जायेगी। 

Post a Comment

0 Comments