如何在XML中使用XLink

时间:2012-03-06 19:57:36

标签: xml loops hyperlink xlink

我是XML的新用法。我需要添加一个指向表的开销节点的超链接,元素ID称为ExpName。我发现的最好的方法是使用XLink在XML中创建一个超链接,但我尝试了很多次,我无法让页面工作。有人可以打发我吗?该页面位于: http://www.studentsofferingsupport.ca/portal/Finance/CashTracker.php

$xml_output  = "<?xml version=\"1.0\"?>";
$xml_output .= "<list_of_transactions>";
$xml_output .="<homepages xmlns:xlink='http://www.w3.org/1999/xlink'>";

$sql_select6 = "SELECT Finance_Expenses.ExpID, Finance_Expenses.ExpName,
  Finance_Expenses.Image, lm_user_profiles.FirstName,
  lm_user_profiles.LastName, Finance_Expenses.DateSubmit,
  Finance_Expenses.ChequeNo, Finance_MethodOfPayment.Type
FROM Finance_Expenses, lm_user_profiles, Finance_MethodOfPayment
WHERE Finance_Expenses.user_id = lm_user_profiles.user_id
  AND Finance_MethodOfPayment.PayID = Finance_Expenses.PayID
  AND Finance_Expenses.School IN('".join("','", $chapter)."')
  AND Finance_Expenses.ExpID = '$transID'";

$result6 = mysql_query($sql_select6) or die(mysql_error());

$resultCount6 = mysql_num_rows($result6);

$row6  =  mysql_fetch_array($result6);
#Store transaction detail

$transDetail = "EXPENSE paid by  " . $row6['Type']
  . " " . $row6['Image'] . "";

$transDetail .= $row6['ExpName']."(".$row6['DateSubmit'].") \n";

$row6  =  mysql_fetch_array($result6);
break;

#Populate XML document
$xml_output .= "<Transaction>";
$xml_output .= "<Date>" . $dateBank . "</Date>";
$xml_output .= "<Detail>" . $transDetail . "</Detail>";
$xml_output .= "<DetailType>" . $detailType . "</DetailType>";
$xml_output .= "<Amount>" . $amount . "</Amount>";
$xml_output .= "<TransType>" . $transType . "</TransType>";
$xml_output .= "<DayBalance>" . $dayBalance . "</DayBalance>";
 //$xml_output .= "<a>" . $chapter[0] . "</a>";
$xml_output .= "</Transaction>";

1 个答案:

答案 0 :(得分:0)

使用XHTML作为命名空间而不是XLink,以使超链接正常工作:

<homepages xmlns='http://www.w3.org/1999/xhtml'>

将元素的ID添加到超链接:

"<a href='#ExpName'>" . $chapter[0] . "</a>";