问题列表 - 第42078页

如何在PHP中创建一个空/空的SimpleXMLElement?

我正在尝试使用PHP文档使用PHP 5的内置SimpleXMLElement类构建XML文档(用于AJAX).我想从一个空白的平板开始并按元素构建XML元素,但是我发现如果SimpleXMLElement不从一些现有的XML代码开始构建一个,我就没有办法.我无法成功地将空字符串("")传递给SimpleXMLElement构造函数,所以目前我正在传递最外层标记的XML,然后从那里构建.这是我的代码:

// Start with a "blank" XML document.
$xml = new SimpleXMLElement("<feature></feature>");

// Add various children and attributes to the main tag.
$xml->addAttribute("id", $id);
$xml->addChild("title", $feature['title']);
$xml->addChild("summary", $feature['summary']);
// ...

// After the document has been constructed, echo out the XML.
echo $xml->asXML();
Run Code Online (Sandbox Code Playgroud)

有更清洁的方法吗?

php simplexml

11
推荐指数
1
解决办法
9807
查看次数

如何在iframe中获取页面标题?

首先我有一个简单的iframe

<iframe src="http://www.google.com"></iframe>
Run Code Online (Sandbox Code Playgroud)

我还有一个按钮来提醒谷歌的标题

<input type="button" value="gettitle" />
Run Code Online (Sandbox Code Playgroud)

然后我想用jquery来获取iframe内部html的标题

    $("input ").click(function () {
        alert($('iframe').contents().find("title").text());
    });
Run Code Online (Sandbox Code Playgroud)

但它不起作用,这段代码出了什么问题?如何才能正确获得标题?

在线案例

谢谢

html iframe jquery dom title

3
推荐指数
1
解决办法
2246
查看次数

无法使用UIPanGestureRecognizer移动UIImageView

我正在尝试创建一个程序,用户可以使用UIPanGestureRecognizer在屏幕上拖动UIImageView.我尝试了几种不同的方法,但无法弄明白.我不确定是否需要创建发件人/请求者.我的理解是UIImageView需要放在一个可以处理手势的UIView中.在我的程序中,我有一个视图控制器 - AdvancedViewController1.我创建了一个名为AdvancedView1的UIView.在界面生成器中,我已将AdvancedView1插入AdvancedViewController 1.以下是我.h.m控制器和视图的文件.我只包含了相关的代码.如果我很接近,请告诉我,以及如何修复我的代码.在此先感谢您的帮助.

AdvancedViewController1.h
#import <UIKit/UIKit.h>
#import "AdvancedView1.h"
@interface AdvancedViewController1 : UIViewController {
UIWindow *window;
AdvancedView1 *advancedView1;
UIImageView * option1; 
}
@property (retain) IBOutlet AdvancedView1 *advancedView1;
@property (retain) IBOutlet UIImageView *option1;
@end
Run Code Online (Sandbox Code Playgroud)

在IB中,我已将IBOutlet与AdvancedView1链接到UIView,并将选项1链接到我希望能够移动的UIImageView.

AdvancedViewController.m

#import "AdvancedViewController1.h"
#import "AdvancedView1.h"
@implementation AdvancedViewController1
@synthesize advancedView1;
@synthesize option1

- (void)viewDidLoad { 
UIGestureRecognizer *pangr = [[UIPanGestureRecognizer alloc]       initWithTarget:self.advancedView1 action:@selector(pan:)];
pangr.delegate = self;
[self.advancedView1 addGestureRecognizer:pangr];
[pangr release];      
[super viewDidLoad];
}

AdvancedView1.h

#import <UIKit/UIKit.h>
#import "AdvancedViewController1.h"
@class AdvancedView1;
@interface AdvancedView1 : UIView{ …
Run Code Online (Sandbox Code Playgroud)

iphone ipad uigesturerecognizer

4
推荐指数
1
解决办法
8809
查看次数

PHP:Array_unshift不是数字索引

只是想用array_unshift在我的数组前面添加一个新参数,但是:如果我像往常一样,它有一个数字索引.如何拒绝索引,例如...

<?php
$queue = array("a", "B");
array_unshift($queue, "front" => "hello" ); //Not working, this is my question ;)
?>
Run Code Online (Sandbox Code Playgroud)

然后阵列看起来像

Array {
    front => hello
    0 => a
    1 => B
}
Run Code Online (Sandbox Code Playgroud)

php arrays

6
推荐指数
2
解决办法
4796
查看次数

使用std :: placeholder需要哪些库?

目前我正在尝试生成组合,我使用以下代码:

#include <vector>
#include <algorithm>
#include <iostream>
#include <functional>

template<class RandIt, class Compare>
bool next_combination(RandIt first, RandIt mid, RandIt last)
{
    std::sort(mid, last, std::bind(std::less<int>(), std::placeholders::_2
                                            , std::placeholders::_1));
    return std::next_permutation(first, last, std::less<int>());
}
Run Code Online (Sandbox Code Playgroud)

使用g ++无法编译说:

next_combo.cpp: In function ‘bool next_combination(RandIt, RandIt, RandIt)’:
next_combo.cpp:10: error: ‘bind’ is not a member of ‘std’
next_combo.cpp:10: error: ‘std::placeholders’ has not been declared
next_combo.cpp:11: error: ‘std::placeholders’ has not been declared
Run Code Online (Sandbox Code Playgroud)

我认为std :: placeholders是在功能上声明的,但现在我很困惑.我应该只使用提升吗?

该项目的其余部分也使用c ++ 0x,那么有更好的方法使用c ++ 0x功能编写它吗?

任何帮助是极大的赞赏 :)

c++ bind

8
推荐指数
2
解决办法
2710
查看次数

在ModelForm中删除父类的字段

我有一个继承自另一个模型的模型(不是抽象)我有一个继承模型的ModelForm,但我不想显示基础模型中的任何字段.除了明确手动将每个字段添加到排除列表之外,实现此目的的最佳方法是什么?

django django-forms

1
推荐指数
1
解决办法
612
查看次数

可以在没有重定向的情况下使用FlashMessenger吗?

我想知道它是否可以使用flash messenger而无需重定向?例如.登录失败后,我想继续显示表单,不需要重定向.

public function loginAction() {
  $form = new Application_Form_Login();

  ...

  if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams())) {
    $authAdapter = new Application_Auth_Adapter($form->getValue('username'), $form->getValue('password'));
    if ($this->auth->authenticate($authAdapter)->isValid()) {
      ...
    } else {
      // login failed
      $this->flashMessenger->addMessage('Login failed. You may have entered an invalid username and/or password. Try again');
    }
  }

  $this->view->form = $form;
}
Run Code Online (Sandbox Code Playgroud)

zend-framework

5
推荐指数
1
解决办法
4963
查看次数

1
推荐指数
1
解决办法
2311
查看次数

如何更改:链接和a:单独悬停为div?

在我的页面中,我已经有了一个a:linka:hover.

但现在我有另一个div标签,我想要不同的a:link,a:hovera:visited.

我该怎么做呢?

css

5
推荐指数
1
解决办法
3万
查看次数

HVGA和WVGA(hdpi)的常规布局,但结果不同

我已经尝试了HVGA和WVGA(hdpi)的XML常规布局,但是当我在AVD中尝试它时却得到了不同的结果。有人可以帮助我吗?谢谢

android

2
推荐指数
1
解决办法
3218
查看次数