0

変数 $html があります

このコードが格納されている

<form action="track_mobile.asp" method="post" name="TrackMobile">
<table width="99%" height="55" border="0" cellpadding="2" cellspacing="0">
                  <tr>
                    <td class="Heading2" colspan="2">&nbsp;Track Any Mobile Location</td>
                  </tr>

<tr>
<td width="21" valign="top" rowspan="2" class="s2stextbox" valign="top"><img src="../images/operators_logo/Tata.png" width="134" height="121" align="left"> </td>
<td width="897" valign="top" class="s2stextbox"><font size="2"><b>Mobile Number:     </b>918888888888</font></td>
</tr>
        <tr>
           <td width="897" valign="top" class="s2stextbox" valign="top"><font size="2">      <b>User Name:</b> We are unable to trace the Name for this Mobile Number<br>
<font size="2"><b>Mobile Operator Name:</b> TATA TELESERVICES<br>
<b>State/Region: </b>Maharashtra</font></td>
</tr>   </table>
</form> 

":(セミコロン)" の後のすべての項目はランダムで、毎回異なります。

エコーを取得するための正しい構文を教えてください

Mobile Number: 918888888888
User Name: We are unable to trace the Name for this Mobile Number
Mobile Operator Name: IDEA
State/Region: Maharashtra

これらはランダムに生成され、毎回異なるため、preg_matchはこの場所を検索し、同じ場所にあるテキストをエコーし​​ます

918888888888
We are unable to trace the Name for this Mobile Number
IDEA
Maharashtra
4

2 に答える 2

0

これは作業ですXPath([ SimpleXMLElement::xpath][1] を参照してください。XPath は次のようになります。

918888888888

/form/table/tr[1]/td[2]/font[substring-after(./text(), ':') -> 

この携帯電話番号の名前を追跡できません

/form/table/tr[2]/td[1]/font[1][substring-after(./text(), ':')

タタテレサービス

/form/table/tr[2]/td[1]/font[2][substring-before(substring-after(./text(), ':'), 'State')

マハラシュトラ

/form/table/tr[2]/td[1]/font[2][substring-after(./text(), 'Region')
于 2013-09-04T17:18:16.463 に答える