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 :)
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With