Difference between revisions of "XML"

From Fab Lab Bcn WIKI
Jump to: navigation, search
(Created page with "'''Extensible Markup Language''' ('''XML''') is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification<ref>{{cite web|url=...")
 
(Processing)
Line 11: Line 11:
 
== Processing ==
 
== Processing ==
  
<code>// The following short XML file called "sites.xml" is parsed  
+
<code>
 +
 
 +
// The following short XML file called "sites.xml" is parsed  
 
// in the code below. It must be in the project's "data" directory
 
// in the code below. It must be in the project's "data" directory
 
// <?xml version="1.0"?>
 
// <?xml version="1.0"?>
Line 32: Line 34:
 
     println(id + " : " + url + " : " + site);     
 
     println(id + " : " + url + " : " + site);     
 
   }
 
   }
}</code>
+
}
 +
 
 +
</code>
  
 
http://processing.org/reference/XMLElement.html
 
http://processing.org/reference/XMLElement.html

Revision as of 10:54, 7 December 2011

Extensible Markup Language (XML) is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification<ref>Template:Cite web</ref> produced by the W3C, and several other related specifications, all gratis open standards.<ref>Template:Cite web</ref>

The design goals of XML emphasize simplicity, generality, and usability over the Internet.<ref name="XML Goals">Template:Cite web</ref> It is a textual data format with strong support via Unicode for the languages of the world. Although the design of XML focuses on documents, it is widely used for the representation of arbitrary data structures, for example in web services.

Many application programming interfaces (APIs) have been developed that software developers use to process XML data, and several schema systems exist to aid in the definition of XML-based languages.

Edit and create

Parsing

Processing

// The following short XML file called "sites.xml" is parsed // in the code below. It must be in the project's "data" directory // <?xml version="1.0"?> // <websites> // <site id="0" url="processing.org">Processing</site> // <site id="1" url="mobile.processing.org">Processing Mobile</site> // </websites>

XMLElement xml;

void setup() {

 size(200, 200);
 xml = new XMLElement(this, "sites.xml");
 int numSites = xml.getChildCount();
 for (int i = 0; i < numSites; i++) {
   XMLElement kid = xml.getChild(i);
   int id = kid.getInt("id"); 
   String url = kid.getString("url"); 
   String site = kid.getContent();
   println(id + " : " + url + " : " + site);    
 }

}

http://processing.org/reference/XMLElement.html