累加值xml

时间:2018-09-19 20:05:49

标签: php xml simplexml

我希望每次访问者访问页面时都将XML节点增加1。

这是我当前拥有的,但是它一直返回值1 ...

landingsmap <- ggplot() + 
  scale_x_continuous(limits=c(-126, -116), expand=c(0,0)) + 
  scale_y_continuous(limits=c(32, 42), expand=c(0,0)) + 
  geom_sf(data=simpleblocks, aes(colour=number_fish, fill=number_fish)) + 
  scale_colour_gradient(low="lightcoral", high="darkred", name="Number of Fish") + 
  scale_fill_gradient(low="lightcoral", high="darkred", name="Number of Fish") +
  geom_sf(data=camap, colour="black") + 
  theme(
    panel.background = element_rect(fill="skyblue4", size=0.5, linetype="solid"),
    legend.position = c(0.78, 0.5)
    ) + 
  NULL
landingsmap 

1 个答案:

答案 0 :(得分:1)

问题在于,您在加载文件之前先设置了$xPostName,所以此时没有任何值,然后在其中加1以更新值...

$xPostName =   $xml->up;
//load xml file to edit
$xml = simplexml_load_file($_GET['id'].'/info.xml');
$xml->up = $xPostName +1;

因此,在加载文件后将其移动到...

//load xml file to edit
$xml = simplexml_load_file($_GET['id'].'/info.xml');
$xPostName =   $xml->up;
$xml->up = $xPostName +1;

或者直接增加值...

$xml = simplexml_load_file('out.xml');

$xml->up +=1;