2014-10-06 87 views
0

我决定使用XFormat节点从使用PHP的API调用中获取我的JSON POSTFIELDS。下面是 从JSON字符串转化为为XMLDocument的XML数据的结果:Flowgear中未定义名称空间前缀'salesValue'

<root> 
    <salesValue>5000</salesValue> 
    <authorId>2</authorId> 
</root> 

https://developers.flowgear.net/kb/Node:XPath_Match读我想出了下面的XPath 抓住这些价值观很感兴趣,并注入他们对我的SQL查询:

  • salesValue:根/ salesValue
  • AUTHORID:根/ AUTHORID

我已经选择XML作为我的转义价值,该属性不知道它应该是哪一个。我得到的错误是:

(XFormat 1.0.0.1):名称空间前缀'salesValue'未定义。

我想这个问题与我如何格式化我的XPath,试图获取这些值。在我XFormat节点表达属性的SQL查询如下所示:

SELECT `Book`.`id` , `Book`.`name` , `Book`.`isbn` , `Book`.`quantity_in_stock` , `Book`.`price`  , (`Book`.`quantity_in_stock` * `Book`.`price`) AS `sales`, 
concat(`Author`.`name`, ' ', `Author`.`surname`) AS `author` FROM `books` AS `Book` LEFT JOIN  authors AS `Author` ON (`Book`.`author_id` = `Author`.`id`) 
WHERE (`Book`.`quantity_in_stock` * `Book`.`price`) > {salesValue} AND `Book`.`author_id` = " {authorId}" 

我应该有这些值在查询注入我能够继续前进。下面是我的脚本使用通过API调用的工作流程:

   try{ 
    $results = invokeFlowgear("https://domain.flowgear.io/authorbooksaleslist", "login", "passwrd", 30, 
     array(
     'salesValue' => 5000.00, 
     'authorId' => 2 
    )); 

    var_dump($results); 


      }catch(Exception $exc){ print $exc->getMessage(); } 

预先感谢您...

回答

0

在XPath的元素的地址最多可以有三个部分:

  1. 本地名称或*(所有)元素:foohtml - 这是强制性的
  2. 一个namepspace前缀/别名:n1:fooxhtml:html - 没有前缀,意味着没有命名空间
  3. 的轴定义元素的初始列表:children::foofollowing-sibling::xhtml:div - 默认为children

你的XML没有命名空间。它只是格格不入。所以提供'salesValue'或'authorId'作为名称空间前缀是错误的。

从文档根寻址的值:

  • /root/salesValue
  • /root/authorId

我认为TEST1:该示例中的链接的页面只是提供一个标识符,以XPath表达式而不是它的一部分。

相关问题