Skip to content

Instantly share code, notes, and snippets.

@kamioftea
Last active July 29, 2018 18:46
Show Gist options
  • Save kamioftea/b3ea0de6af0a3fef519ddcbe3da7d27b to your computer and use it in GitHub Desktop.
Save kamioftea/b3ea0de6af0a3fef519ddcbe3da7d27b to your computer and use it in GitHub Desktop.
HTML Parsing
var str = '<span class="badge badge-success" style="cursor:default" title="Local Dispatch">L</span>';
var parent = document.createElement("div");
parent.innerHTML = str;
console.log(parent.firstChild.className);
// or with JQuery
console.log($(str).prop('class'));
<?php
$str = '<span class="badge badge-success" style="cursor:default" title="Local Dispatch">L</span>';
$xml = new SimpleXMLElement($str);
var_dump((string) $xml->attributes()['class']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment