Why is XmlSerializer deprecated?

223 views
Skip to first unread message

Gonzalo Chumillas

unread,
Aug 25, 2014, 6:39:55 AM8/25/14
to mi...@dartlang.org
Hello Everybody,
Why is XmlSerializer deprecated? How could I print a string representation of an XML node?

Thank you.

Günter Zöchbauer

unread,
Aug 25, 2014, 1:32:32 PM8/25/14
to mi...@dartlang.org
There was a similar question on SO http://stackoverflow.com/questions/25483978
I guess it is because XML support will be removed from Chrome https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/zIg2KC7PyH0%5B1-25-false%5D

Cogman

unread,
Aug 25, 2014, 2:32:07 PM8/25/14
to mi...@dartlang.org
Looks like they aren't planning on removing xml support, but rather xslt support.  They were saying that if they remove xslt support, it would be much easier to drop libxml and start using their own html parsing engine to handle xml (instead of effectively having two xml reading implementations)

Even then, it looks like they might be adding xslt support in the form of a javascript library.

From the post

 Removing support for XSLT is a necessary step towards removing Blink's dependency on libxml.  Over the long term, we would like to remove our dependency on libxml and re-use machinery from the HTML parser to implement high-performance handling of XML-based content.


--
For other discussions, see https://groups.google.com/a/dartlang.org/
 
For HOWTO questions, visit http://stackoverflow.com/tags/dart
 
To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+uns...@dartlang.org.

Günter Zöchbauer

unread,
Aug 25, 2014, 4:54:30 PM8/25/14
to mi...@dartlang.org
Seems I should have read a bit more ;-)

Cogman

unread,
Aug 26, 2014, 6:59:57 PM8/26/14
to mi...@dartlang.org
NP.  I could be wrong, but it looks like it is already removed from trunk (It isn't all that easy to browse on the internet and I didn't necessarily want to checkout dart's source).

I would be interested to know the real reason it was deprecated.

Gonzalo Chumillas

unread,
Aug 27, 2014, 9:52:54 AM8/27/14
to
Thanks for the replies. Here's my serializer function:

/**
 * Gets a string representation of [node].
 */
String node2str(Node node) {
  var str = new StringBuffer();

  if (node is Text) {
    str.write(node.text);
  } else if (node is Comment) {
    str.write('<!--${node.text}-->');
  } else if (node is Element) {
    var escape = const HtmlEscape(HtmlEscapeMode.ATTRIBUTE);
    var tagName = node.nodeName.toLowerCase();
    
    str.write('<$tagName');
    
    node.attributes.forEach((String attrName, String value) {
      str.write(' $attrName="${escape.convert(value)}"');
    });
    
    if (node.childNodes.length > 0) {
      str.write('>');
      
      node.childNodes.forEach((Node item) {
        str.write(node2str(item));
      });
      
      str.write('</$tagName>');
    } else {
      str.write(' />');
    }
  }
  
  return str.toString();
}
Reply all
Reply to author
Forward
0 new messages