Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Thursday, 17 January 2013

Best Free XML Editors and Viewers

Best Free XML Editors and Viewers

Here is the list of best free XML Editors and Viewers which will make it easy for you to understand XML. Professional XML editors will help you to write error-free XML documents, validate your XML against a DTD or a schema, and force you to stick to a valid XML structure.
An XML editor should be able to:

1. Add closing tags to your opening tags automatically
2. Force you to write valid XML
3. Verify your XML against a DTD
4. Verify your XML against a Schema
5. Color code your XML syntax

Need of an XML Editor

Today XML is an important technology, and development projects use XML-based technologies like:

1. XML Schema to define XML structures and data types
2. XSLT to transform XML data
3. SOAP to exchange XML data between applications
4. WSDL to describe web services
5. RDF to describe web resources
6. XPath and XQuery to access XML data
7. SMIL to define graphics
8. To be able to write error-free XML documents, you will need an intelligent XML editor!

List of Best Free XML Editors and Viewers

1. XML Notepad

XML Notepad is Microsoft’s contribution to the XML editor forum. Based in class on the popular text editor dispensed with Windows operating systems, Notepad, the XML module offers a semi WYSIWYG design. The tree view and text view are color coded and use bold shapes to identify the elements and their family relationships for XPath navigation. Overall, Microsoft’s XML Notepad is not a terrible choice for those with a basic understanding of XML. Additionally, the program helps design and produce XSL style sheets to accompany the XML information and create an output stream.

2. FOXE XML Editor

First Objective Software Inc. produces a free editor that works as an advanced text editor . FOXE offers some basic tools for authoring code but does not delve too far into styling. The program does provide some inherent code that allows you to navigate files, define XPath information and split documents. This is a decent choice for those learning to take baby steps in XML production. The tree view and embedded scripts make FOXE a better choice than a standard text editor, but the program still makes you work to learn  to write effective XML.

3. Serna Free – Open Source XML Editor

Serna is a WYSIWYG editor produced by Syntext that goes beyond the norm. Like most XML editors, Serna begins with the classic split screen and works exclusively in a WYSIWYG style. It will take some practice to get used to the interface, but once you understand the basic tools, creating your document is straightforward. This is an editor for someone who has a clear understanding of XML technology and looking for a shortcut. Newcomers need to understand the basics of valid XML before attempting to work within the Serna environment..

What is an XML File or XML Document? Why to use XML?

What is an XML File or XML Document? Why to use XML?

This article covers basics of XML. We will discuss some benefits and advantages of XML.

What is XML?

XML is Extensible Markup Language. XML is a specification developed by W3C. XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed with relatively little human intervention and exchanged across diverse hardware, operating systems, and applications.

In brief, XML offers a widely adopted standard way of representing text and data in a format that can be processed without much human or machine intelligence. Information formated in XML can be exchanged across platforms, languages, and applications, and can be used with a wide range of development tools and utilities.

Example of XML Document

<bag label="Glenns Food" storage-date="October, 2001">
  <item>Candy Bar</item>
  <bag label="Vegetables" storage-date="Oct 11 2001">
 <item>Carrot</item>
 <item>Lettuce</item>
  </bag>
  <bag label="Fruits" storage-date="Oct 13 2001">
 <item>Pear</item>
  </bag>
</bag>

Difference between HTML and XML

XML is similar enough to HTML in its actual format. But there are two fundamental differences:

1. Separation of form and content -- HTML mostly consists of tags defining the appearance of text; in XML, the tags generally define the structure and content of the data, with actual appearance specified by a specific application or an associated stylesheet.

2. XML is extensible -- tags can be defined by individuals or organizations for some specific application, whereas the HTML standard tagset is defined by the World Wide Web Consortium (W3C).  

Advantages of XML

1. Simplicity

Information coded in XML is easy to read and understand, plus it can be processed easily by computers.

2. Openness

XML is a W3C standard, endorsed by software industry market leaders.

3. Extensibility

There is no fixed set of tags. New tags can be created as they are needed.

4. Self-description

In traditional databases, data records require schemas set up by the database administrator. XML documents can be stored without such definitions, because they contain meta data in the form of tags and attributes.

XML provides a basis for author identification and versioning at the element level. Any XML tag can possess an unlimited number of attributes such as author or version.

5. Contains machine-readable context information

Tags, attributes and element structure provide context information that can be used to interpret the meaning of content, opening up new possibilities for highly efficient search engines, intelligent data mining, agents, etc.

This is a major advantage over HTML or plain text, where context information is difficult or impossible to evaluate.

6. Separates content from presentation

XML tags describe meaning not presentation. The look and feel of an XML document can be controlled by XSL style sheets, allowing the look of a document (or of a complete Web site) to be changed without touching the content of the document. Multiple views or presentations of the same content are easily rendered.

7. Supports multilingual documents and unicode

This is important for the internationalization of applications.

8. Facilitates the comparison and aggregation of data

The tree structure of XML documents allows documents to be compared and aggregated efficiently element by element.

9. Can embed multiple data types

XML documents can contain any possible data type - from multimedia data (image, sound, video) to active components (Java applets, ActiveX).

10. Can embed existing data

Mapping existing data structures like file systems or relational databases to XML is simple. XML supports multiple data formats and can cover all existing data structures and

11. Provides a 'one-server view' for distributed data

XML documents can consist of nested elements that are distributed over multiple remote servers. XML is currently the most sophisticated format for distributed data - the World Wide Web can be seen as one huge XML database.

Tuesday, 1 January 2013

PHP JSON and XML Parser: How to Parse JSON and XML using PHP Script?

PHP JSON and XML Parser: How to Parse JSON and XML using PHP Script?

Parsing XML and JSON is very common application requirement as all the webservices provide data in the form of JSON and XML. PHP has very simple ways to parse XML and JSON. To parse JSON with PHP script, you have to use "json_decode" PHP function. We have given below the PHP JSON Parser code which is very simple. Similarly, using PHP script you can easily create PHP XML Parser. Using simplexml_load_string function, you can easily parse XML in PHP.

Below is the PHP code to parse JSON and XML:

PHP JSON Parser: How to Parse JSON using PHP Script?

$json_string='{"id":101,"name":"Harry","email":"harry@example.com","interest":["wordpress","php"]} ';
$obj=json_decode($json_string);
echo $obj->name; //prints Harry
echo $obj->interest[1]; //prints php

PHP XML Parser: How to Parse XML using PHP Script?

//xml string
$xml_string="<?xml version='1.0'?>
<users>
   <user id='101'>
      <name>Harry</name>
      <email>harry@example.com</name>
   </user>
   <user id='102'>
      <name>Harry2</name>
      <email>harry2@example.com</name>
   </user>
</users>";

//load the xml string using simplexml
$xml = simplexml_load_string($xml_string);

//loop through the each node
foreach ($xml->user as $user)
{
   //access attribute
   echo $user['id'], '  ';
   //subnodes are accessed by -> operator
   echo $user->name, '  ';
   echo $user->email, '<br />';
}