Last active
July 29, 2018 18:46
-
-
Save kamioftea/b3ea0de6af0a3fef519ddcbe3da7d27b to your computer and use it in GitHub Desktop.
HTML Parsing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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