この正規表現の作成を手伝ってくれる人はいますか?
例:
<br /> function getTagInfo(e){<br /> var str='';<br /> if(jQuery(e).attr('id')){<br /> str += 'id:'+jQuery(e).attr('id');<br /> }else if(jQuery(e).attr('class')){<br /> str += 'class:'+jQuery(e).attr('class');<br /> <br /> }else{<br /> str += '既没设置id也没设置class属性';<br /> }<br /> str += '\ntagName:'+jQuery(e).get(0).tagName;<br /> alert(str);<br /> }<br />
<br /> <div id='myDivId' class="myDivClass" onclick="getTagInfo(this)">点我</div><br /> <span id='mySpanId' class="mySpanClass" onclick="getTagInfo(this)">点我</span><br />
<br /> <?php<br /> $html = '<div id="myid" class="myclass"></div>';<br /> $dom = new DOMDocument();<br /> @$dom->loadHTML($html);<br /> $x = new DOMXPath($dom); <br /> <br /> foreach($x->query("//*") as $node) <br /> {<br /> echo $node->getAttribute("id"); //myid<br /> echo '<br />';<br /> echo $node->getAttribute("class"); //myclass<br /> echo '<br />';<br /> echo $node->nodeName; // div<br /> } <br /> ?><br />