XML Key Components in Hindi
RGPV University / DIPLOMA_CSE / Web Technology
XML Key Components in Hindi
XML Key Components in Hindi
Introduction to XML
XML (Extensible Markup Language) एक मानव-पठनीय डेटा फॉर्मेट है जिसे मशीनों द्वारा भी आसानी से पढ़ा और लिखा जा सकता है। यह एक संरचित फॉर्मेट है, जिसका मुख्य उद्देश्य डेटा को स्टोर और ट्रांसफर करना है। XML का उपयोग इंटरनेट पर डेटा को स्टोर करने और उसे एक जगह से दूसरी जगह ट्रांसफर करने के लिए किया जाता है। XML के उपयोग से हम डेटा को आसानी से संरचित कर सकते हैं, और इसे विभिन्न प्लेटफार्मों पर आसानी से शेयर कर सकते हैं।
XML Components
- Elements: XML में हर डेटा को Element के रूप में परिभाषित किया जाता है। Elements के अंदर डेटा स्टोर होता है और इन्हें
<element>data</element>
के रूप में लिखा जाता है। Elements का नाम स्वयं से descriptive होता है और यह XML document की संरचना का मुख्य हिस्सा होता है। - Attributes: XML में attributes का उपयोग elements के अंदर additional जानकारी रखने के लिए किया जाता है। Attributes को
<element attribute="value">
के रूप में लिखा जाता है। - Tags: XML tags का उपयोग elements को परिभाषित करने के लिए किया जाता है। यह opening और closing tags में होते हैं, जैसे कि
<element>data</element>
।
XML Document Structure
XML document की संरचना बहुत सरल होती है, जिसमें एक root element होता है, और इस root element के अंदर अन्य elements होते हैं। उदाहरण के लिए, एक XML document का structure कुछ इस प्रकार हो सकता है:
<root>
<element>value</element>
</root>
यह structure बहुत महत्वपूर्ण है क्योंकि XML document में हर element का एक hierarchical structure होता है। यह document के अंदर मौजूद data के relation को स्पष्ट करता है।
XML Syntax Rules
- Case Sensitivity: XML में tags case-sensitive होते हैं, अर्थात
<element>
और<ELEMENT>
अलग होते हैं। - Well-formed Document: XML document को well-formed होना चाहिए, इसका मतलब है कि सभी tags properly closed होने चाहिए, और data के अंदर कोई invalid characters नहीं होने चाहिए।
- Quotes for Attributes: XML में attributes के लिए double quotes (" ") का उपयोग किया जाता है, जैसे कि
<element attribute="value">
।
XML Declaration
XML declaration document के सबसे ऊपर होता है और इसे बताने का काम करता है कि यह एक XML document है। यह एक optional statement होता है, जो XML document के encoding और version को specify करता है। उदाहरण के लिए:
<?xml version="1.0" encoding="UTF-8"?>
यह declaration XML document के प्रारंभ में होता है और इसे document की encoding और version को दर्शाने के लिए उपयोग किया जाता है।
XML Namespaces
XML namespaces का उपयोग XML document में element और attribute के नामों के conflict को रोकने के लिए किया जाता है। यह विशेष रूप से तब महत्वपूर्ण होता है जब एक XML document में विभिन्न sources से data combine किया जाता है। Namespace के बिना, एक ही नाम के elements को अलग-अलग contexts में confusion उत्पन्न कर सकते हैं। Namespace को इस प्रकार define किया जाता है:
<root xmlns:ns="http://example.com/ns">
<ns:element>value</ns:element>
</root>
यह XML document में namespaces का उपयोग करने का तरीका है। यहाँ xmlns:ns="http://example.com/ns"
namespace को define करता है।
XML Processing Instructions
XML processing instructions (PI) XML document में additional information रखने के लिए होते हैं, जो कि XML parser को specific instructions देते हैं। Processing instructions का syntax इस प्रकार होता है:
<?instruction data?>
यह instructions XML document के parser को यह बताने का काम करती हैं कि डेटा को किस प्रकार से process किया जाना चाहिए।
XML Comments
XML document में comments का उपयोग information देने, और temporary data को document में रखने के लिए किया जाता है। XML comments को इस प्रकार लिखा जाता है:
<!-- This is a comment -->
Comments का उपयोग primarily documentation purposes के लिए किया जाता है, और यह XML processing में कोई effect नहीं डालते हैं।
FAQs
XML (Extensible Markup Language) एक markup language है जो structured data को स्टोर और ट्रांसफर करने के लिए उपयोग की जाती है। XML human-readable format में होता है और इसे किसी भी programming language में आसानी से पढ़ा और लिखा जा सकता है।
XML के मुख्य घटक होते हैं: Elements, Attributes, Tags, Document Structure, XML Declaration, Namespaces, और Processing Instructions। ये सभी घटक XML document को संरचित करने और उसे सही तरीके से parse करने के लिए महत्वपूर्ण होते हैं।
XML element का syntax इस प्रकार होता है: <element>data</element>
। यह एक opening और closing tag के बीच में डेटा रखता है। हर element का नाम descriptive होता है और यह document की संरचना का मुख्य हिस्सा होता है।
XML attributes elements के अंदर extra information रखने के लिए उपयोग किए जाते हैं। इन्हें element tag में value के रूप में define किया जाता है, जैसे <element attribute="value">
। यह element के बारे में अतिरिक्त जानकारी प्रदान करते हैं।
XML declaration document के सबसे ऊपर होती है और इसका उपयोग XML document के version और encoding को specify करने के लिए किया जाता है। उदाहरण के लिए: <?xml version="1.0" encoding="UTF-8"?>
यह declaration XML parser को document के format के बारे में जानकारी देता है।
XML namespaces का उपयोग element और attribute के नामों के conflict को रोकने के लिए किया जाता है। जब विभिन्न sources से data combine किया जाता है, तो namespaces का उपयोग करके नामों को unique बनाया जाता है। Namespace को इस प्रकार define किया जाता है: <element xmlns:ns="http://example.com/ns">data</element>