Latest stories

Differences between XML and JSON

D

JSON represents JavaScript Object Notation. It’s an open-standard document position that is utilized for program server correspondences. It’s a language-autonomous information position. XML represents Extensible Markup Language. It’s a lot of decides that help the clients to encode reports in a comprehensible organization and machine-lucid.

Give us a chance to ponder substantially more about JSON versus XML in detail:

“Correspondence is fundamental”. This announcement can be cited with innumerable models. In specialized term correspondence intends to share information and data. The bodies playing out this correspondence can be a framework or server. Since people have composed themselves into an intricate arrangement with the progression in innovation and which has additionally driven us to make organizes that suit our needs.

At the point when we request that PCs procedure things, in real practice it is stacking that information. This information stacking is urgent in light of the fact that the CPU needs to add this to memory. During the time spent doing this, it is putting away numbers to peruse; the importance of these information relies based on elucidation.

Presently comes the correspondence or information trade part. The genuine issue lies here when the correspondence is intended to occur among incalculable frameworks and systems accessible worldwide and how the translation happens. JSON versus XML is the most widely recognized organization favored for information trade on the web.

To maintain a strategic distance from these issues there must be a typical phrasing that is pertinent and more clear among frameworks over the globe. This invalidates the requirement for understandings. This is pivotal in light of the fact that a few principles and regular wording are required that every PC can concede to.

Key Differences between JSON vs XML

Both are popular choices in the market; let us discuss some of the major Difference Between JSON vs XML :

  • JSON has a file extension of .json whereas for XML the file extension is .xml.
  • JSON has “Data interchange” file format whereas XML has “Markup Language” file format.
  • JSON has been extended from JavaScript whereas XML from SGML (Standard Generalized Markup Language).
  • JSON came into existence in 2002 (by Douglas Crockford) whereas XML in 1996 (by W3C).
  • JSON complexity level regarding learning and understanding is easier than XML.
  • JSON is data-oriented whereas XML is document oriented.
  • JSON does not provide display properties whereas XML does (as it’s a Markup Language).
  • JSON supports array whereas XML does not.
  • JSON is less secured than XML.
  • JSON files are more human readable than its counterpart XML.
  • JSON only supports text and number data types whereas XML has varieties like text, numbers, images, charts, graphs etc.

Generating an XML snippet from an XML schema

G

The XML editor has the ability to generate XML snippets from an XML Schema definition language (XSD) schema. For example, as you are authoring an XML file, while positioned next to the element name, you can press Tab to populate the element with XML data generated from the schema information for that element.

This feature is only available on elements. The following rules also apply:

  • The element must have an associated schema type; that is, the element must be valid according to some associated schema. The schema type cannot be abstract and the type must contain the required attributes and/or required child elements.
  • The current element in the editor must be empty with no attributes. For example, the following are all valid
    • <Account
    • <Account>
    • <Account></Account>
  • The cursor must be located immediately to the right of the element name.

The generated snippet contains all required attributes and elements. If minOccurs is greater than one, the required minimum number of instances of that element is included in the snippet, up to a maximum of 100 instances. Any fixed values found in the schema result in fixed values in the snippet. xsd:any and xsd:anyAttribute elements are ignored and result in no additional snippet constructs.

Default values are generated and noted as editable values. If the schema specifies a default value, this default value is used. However, if the schema default value is an empty string, the editor generates the default values in the following manner:

  • If the schema type contains any enumeration facets, either directly or indirectly by means of any of members of a union type, the first enumerated value found in the Schema Object Model is used as the default.
  • If the schema type is an atomic type, the editor gets the atomic type and inserts the atomic type name. For a derived simple type it uses the base simple type. For a list type the atomic type is the itemType. For a union, the atomic type is the atomic type of the first memberType.

Example

The steps in this section show you how to use the schema-generated XML snippet feature of the XML editor.

[!NOTE] Before starting these procedures, save the schema file to your local computer.

To create a new XML file and associate it with an XML schema

  1. On the File menu, point to New, and click File.
  2. Select XML File in the Templates pane and click Open.

    A new file is opened in the editor. The file contains a default XML declaration, <?xml version="1.0" encoding="utf-8">.

  3. In the document properties window, click the browse button () on the Schemas field.

    The XSD Schemas dialog box is displayed.

  4. Click Add.

    The Open XSD Schema dialog box is displayed.

  5. Select the schema file and click Open.
  6. Click OK.

    The XML schema is now associated with the XML document.

To generate an XML snippet

  1. Type < in the editor pane.
  2. The members list displays the possible items:

    !– to add a comment.

    !DOCTYPE to add a document type.

    ? to add a processing instruction.

    Contact to add the root element.

  3. Select Contact from the member list and press Enter.

    The editor adds the start tag <Contact and positions the cursor after the element name.

  4. Press Tab to generate XML data for the Contact element based on its schema information.

Input

The following schema file is used by the walkthrough.

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="phoneType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Voice"/>
      <xs:enumeration value="Fax"/>
      <xs:enumeration value="Pager"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="Contact">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Name">
          <xs:simpleType>
            <xs:restriction base="xs:string"></xs:restriction>
          </xs:simpleType>
        </xs:element>
        <xs:element name="Title"
                    type="xs:string" />
        <xs:element name="Phone"
                    minOccurs="1"
                    maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Number"
                          minOccurs="1">
                <xs:simpleType>
                  <xs:restriction base="xs:string"></xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="Type"
                          default="Voice"
                          minOccurs="1"
                          type="phoneType"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Output

Following is the XML data that is generated based on the schema information associated with the Contact element. Items marked as bold designate editable fields in the XML snippet.

<Contact>
  <Name>name</Name>
  <Title>title</Title>
  <Phone>
    <Number>number</Number>
    <Type>Voice</Type>
  </Phone>
</Contact>

What is XML (Extensible Markup Language)?

W

Extensible Markup Language (XML) is used to describe data. The XML standard is a flexible way to create information formats and electronically share structured data via the public Internet, as well as via corporate networks.

XML code, a formal recommendation from the World Wide Web Consortium (W3C), is similar to Hypertext Markup Language (HTML). Both XML and HTML contain markup symbols to describe page or file contents. HTML code describes Web page content (mainly text and graphic images) only in terms of how it is to be displayed and interacted with.


What is XML?

  • XML stands for eXtensible Markup Language
  • XML is a markup language much like HTML
  • XML was designed to store and transport data
  • XML was designed to be self-descriptive
  • XML is a W3C Recommendation

XML Does Not DO Anything

Maybe it is a little hard to understand, but XML does not DO anything.

This note is a note to Tove from Jani, stored as XML:

<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don’t forget me this weekend!</body>
</note>

The XML above is quite self-descriptive:

  • It has sender information.
  • It has receiver information
  • It has a heading
  • It has a message body.

But still, the XML above does not DO anything. XML is just information wrapped in tags.

 

Note

To: Tove

From: Jani

Reminder

Don’t forget me this weekend!


The Difference Between XML and HTML

XML and HTML were designed with different goals:

  • XML was designed to carry data – with focus on what data is
  • HTML was designed to display data – with focus on how data looks
  • XML tags are not predefined like HTML tags are

Recent Posts

Recent Comments

Archives

Categories

Meta