Proposal: native XML object support.

guest271314 guest271314 at gmail.com
Tue May 14 07:09:16 UTC 2019


> I prefer JSON over XML any time but the only area where JSON can't
compete with XML is UI.

XML is also currently specified as the language used by SSML.

Why does a JavaScript plain object need to be created when the XML document
itself can be used to read/write values?

```
const createXMLPlainObject = xml_string => Object.create(null, (() => {
  const xml = (new DOMParser()).parseFromString(`<?xml
version="1.0"?>${xml_string}`, "application/xml");
  const element = xml.documentElement;
  return {name:{writable:false, value: element.nodeName}, children:
{writable: false, value: element.children}}
})());
```

On Tue, May 14, 2019 at 5:15 AM Ed Saleh <medozs at outlook.com> wrote:

> Hello,
>
> I am proposing to support XML object native in JavaScript so the following
> code would be possible
>
>     let foo = <input type="button" value = "Ok"\>
>
> Which creates an object called foo with name = "input" and value = "Ok",
> children = null, and constructor = null
>
> `constructor` property would include a constructor to be called when a new
> XML object is created.
>
> While `childern` would include any inner XML items inside the XML element.
>
> It's nature to support XML as object natively next as JSON format is
> already supported natively.
>
> Supporting XML would open new possibilities notably in the UI side as we
> would be able to merge UI with Controller logic code.
>
> This is similar to React framework.
>
> Thank you,
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190514/4b02e69a/attachment-0001.html>


More information about the es-discuss mailing list