数据,来自我的xml文件的值,基于发布的名称。
这是我的xml文件:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct linkedList
{
int data;
struct linkedList *next;
};
struct linkedList* createNode(int value)
{
struct linkedList *node;
node = malloc(sizeof(struct linkedList));
node->next = malloc(sizeof(struct linkedList));
node->next = NULL;
node = NULL;
return node;
}
//insert a node at the top of the linked list
struct linkedList* insertTop(struct linkedList* top,struct linkedList* node)
{
if(top == NULL)//the element we insert is the 1st element for the linked list
{
node->next = NULL;
//the first element points to NULL since it has no successors
}
else//there is already an element in the list
{
node->next = top;
}
return node;
}
void iterate(struct linkedList* top)
{
while(top->next != NULL)
{
printf("Data = %d\n", top->data);
top = top->next;
}
}
int main()
{
struct linkedList *a,*b,*c,*root;
a = createNode(2);
b = createNode(10);
c = createNode(23);
root = insertTop(NULL,a);//these 3 lines provoke a segmentation fault
root = insertTop(root,b);
root = insertTop(root,c);
iterate(root);//the result I expect here is 23,10,2
return 0;
}
这是我的php文件:
<object>
<name>test 1</name>
<data>some data</data>
<value>1</value>
</object>
<object>
<name>test 2</name>
<data>some data 2</data>
<value>2</value>
</object>
这会返回一个空数组,我一直在寻找答案,但我没有找到任何帮助,所以感谢任何帮助
答案 0 :(得分:1)
xpath
中的路径不完整xpath
中的条件语法错误<root>
<object>
<name>test 1</name>
</object>
</root>
$xpath = $xml->xpath("/root/object[name = 'test 1']");
或
$xpath = $xml->xpath("//object[name = 'test 1']");
在行动中看到它:https://eval.in/517818