If there are any then how deeply is xml integrated into language? What primitives are used to manipulate xml document?
PS. I'm not interested in declarative languages such as SQL, XPath, XSLT :)
If there are any then how deeply is xml integrated into language? What primitives are used to manipulate xml document?
PS. I'm not interested in declarative languages such as SQL, XPath, XSLT :)
Powershell has some niceties in dealing with XML, mainly that a node gets dynamic properties representing its sub-nodes. So given the XML
<foo>
<bar/>
<bar/>
</foo>
an XML object created from this has a "foo" property and the object returned by that has a "bar" property.
> $x=[xml]"<foo><bar moo='meh'/><bar meow='bleh'/></foo>" > $x.foo bar --- {bar, bar} > $x.foo.bar[0] moo --- meh > $x.foo.bar[1] meow ---- bleh
Very handy at times.
Depends how you mean by deeply integrated? .net comes with an XML namespace and various classes for dealing with XML documents...
VB.NET 9.0 has XML literals which seems like what you're looking for. This example taken from Imran Shaik blog
<WebMethod()> _
Public Function AllCountriesUsingXMLLiterals() As String
Dim sud As New CountryDataSetTableAdapters.CountryTableTableAdapter
Dim XDataSet As New CountryDataSet.CountryTableDataTable
sud.Fill(XDataSet)
Dim XDoc = _
<Countries xmlns="http://tempuri.org/Schema/Countries">
<%= From country In XDataSet Select <Country Code=<%= country.CountryISO %> Name=<%= country.CountryName %>/> %>
</Countries>
Return XDoc.ToString
End Function
Groovy and Scala have XML literal support, though I think this is generally a really stupid idea.
XQuery ? From the linked article:
XQuery provides the means to extract and manipulate data from XML documents or any data source that can be viewed as XML, such as relational databases or office documents.
It supports for-loops, whiles, let, ordering etc.
Flash's ActionScript 3.0 and JavaScript (ECMAScript languages) are also integrated with XML by E4X.
So code looks something like this (altough this is a simple example and cooler stuff is possible):
var sales = <sales vendor="John">
<item type="peas" price="4" quantity="6"/>
<item type="carrot" price="3" quantity="10"/>
<item type="chips" price="5" quantity="3"/>
</sales>;
alert( sales.item.(@type == "carrot").@quantity );
alert( sales.@vendor );
for each( var price in sales..@price ) {
alert( price );
}
Here are Adobe's docs for working with XML in AS3.0.