问题列表 - 第34938页

为什么我不能删除我刚发现的子元素?NOT_FOUND_ERR

我正在构建一个脚本,它必须修补XML文件,包括用另一个元素替换一个元素列表.以下函数将补丁(包含可能为空的同名元素列表)应用于父元素的同名元素列表(也可能是空列表).(这只是修补逻辑的一小部分).

为什么,当我运行代码时,是否会出现以下错误?

org.w3c.dom.DOMException: NOT_FOUND_ERR: An attempt is made to reference a node in a context where it does not exist.
    at com.sun.org.apache.xerces.internal.dom.ParentNode.internalRemoveChild(ParentNode.java:503)
    at com.sun.org.apache.xerces.internal.dom.ParentNode.removeChild(ParentNode.java:484)
    at CombineSweeps$PTReplaceNodeList.apply(CombineSweeps.java:514)
Run Code Online (Sandbox Code Playgroud)

(第514行标记如下.)据我所知,我刚刚验证了元素是否存在(因为NodeList是实时的,它的第一个条目将始终是下一个匹配或null).有趣的是,这并不总是一个问题.

private static class PTReplaceNodeList extends PTBase {
    private final String name;
    private final String nextElement;
    private final List<Node> childList;

    ...

    int apply(Document document, Node parent, Node node_unused) {
        NodeList nodes;
        // A marker for where to insert our nodes.
        // We make a guess using nextElement (if null, means at end).
        Node refNode …
Run Code Online (Sandbox Code Playgroud)

java xml removechild getelementsbytagname

17
推荐指数
2
解决办法
2万
查看次数

用于在标记之间提取数据的Java正则表达式

我正在尝试一个正则表达式,它从字符串中提取数据

<B Att="text">Test</B><C>Test1</C>
Run Code Online (Sandbox Code Playgroud)

提取的输出需要是Test和Test1.这是我到目前为止所做的事情:

public class HelloWorld {
    public static void main(String[] args)
    {
        String s = "<B>Test</B>";
        String reg = "<.*?>(.*)<\\/.*?>";
        Pattern p = Pattern.compile(reg);
        Matcher m = p.matcher(s);
        while(m.find())
        {
            String s1 = m.group();
            System.out.println(s1);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但这产生了结果<B>Test</B>.谁能指出我做错了什么?

java regex

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

为什么从C#调用PowerShell会抛出System.Management.Automation.CommandNotFoundException?

我正在使用这个c#:

    public bool RunPowershell(string script)
    {
        RunspaceConfiguration runspaceConfig = RunspaceConfiguration.Create();

        using (Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfig))
        {
            runspace.Open();

            using (RunspaceInvoke scriptInvoker = new RunspaceInvoke(runspace))
            {
                scriptInvoker.Invoke(script);
            }
        }

        return true;
    }
Run Code Online (Sandbox Code Playgroud)

要运行此脚本:

      Add-PSSnapin -name Microsoft.SystemCenter.VirtualMachineManager
      $vmm = Get-VMMServer -ComputerName "VmmComputerName"
Run Code Online (Sandbox Code Playgroud)

它在Windows 2003 32位操作系统上运行正常,但在Windows 2008R2 64位上,我收到此错误:

System.Management.Automation.CommandNotFoundException: The term 'Get-VMMServer' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is …
Run Code Online (Sandbox Code Playgroud)

c# powershell

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

使用C的套接字和线程

我是套接字和线程的新手.我有这个代码:

listen(socket_fd, 20);

/* Looooop */
  while (1) {
    newsocket_fd = accept(socket_fd, 
                          (struct sockaddr *) &client_addr, 
                          &client_len);
    if (newsocket_fd < 0) {
      error("ERROR on accept");
    }
    pthread_t thread;
    pthread_create(&thread, NULL, run_thread, (void *) newsocket_fd);
    pthread_join(thread, NULL);
  }
Run Code Online (Sandbox Code Playgroud)

如何为每个新连接启动新线程,而不是为每个请求启动?当新连接进入时,应该启动这些线程,然后这些线程应该等待请求,处理这些请求,最后在关闭连接时返回.每个连接应该有一个线程.这是以下代码run_thread:

void
*run_thread(void *ptr) {
  char buffer[256];
  bzero(buffer, 256);
  int n;
  n = read((int) ptr, buffer, 255);
  if (n < 0) error("ERROR Reading from socket");
  printf("%s\n\n**********\n\n", buffer);

  /* Parse buffer and return result */
  char *result;
  {
    /* First, …
Run Code Online (Sandbox Code Playgroud)

c sockets multithreading posix asynchronous

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

如何在2-D和3-D中在MATLAB中绘制图像(.jpg)?

我有一个二维散点图,在原点我想显示一个图像(不是彩色方块,而是实际图片).有没有办法做到这一点?

我还将绘制一个三维球体,我希望在原点上显示一个图像.

3d matlab plot image

16
推荐指数
1
解决办法
6万
查看次数

将Log4Net RollingFileAppender设置为每周滚动一次

DatePattern字符串需要的东西的SimpleDateFormatter 会接受.

不幸的是,这意味着,开箱即用,这不包括能够将边界设置为周数.有一些方法可以在C#中获得这个值,但是我们可以扩展SimpleDateFormatter或提供不同的实现IDateFormatter并使用它(甚至在自定义中RollingFileAppender)并不明显.

那么我们怎样才能让Log4Net RollingFileAppender每周滚动一次?

.net c# log4net rollingfileappender

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

PHP的错误日志驻留在XAMPP中的哪个位置?

我一直在使用XAMPP for Windows.

PHP的错误日志驻留在XAMPP中的哪个位置?

php apache xampp

83
推荐指数
6
解决办法
15万
查看次数

如何防止加载WPF应用程序?

我希望WPF应用程序仅在某些条件下启动.我尝试了以下但没有成功:

public partial class App : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        if (ConditionIsMet) // pseudo-code
        {
            base.OnStartup(e);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但即使条件不满足,应用程序也能正常运行

.net c# wpf startup

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

是否可以忽略子目录中的.gitignore规则?

我想忽略子目录中的所有.gitignore规则,但root中的.gitignore规则除外.

例如)我已经.gitignore在目录结构中存档了/a.

并且还有.gitignore文件/a/b.假设/aa.txt b.txt文件.

/a/b.config文件..gitignore定义.config/a/b.

.config文件将被忽略.gitignore/a/b.

但我真的想.config通过忽略.gitignore子目录中的规则来跟踪文件.

可能吗?

提前致谢

git

70
推荐指数
4
解决办法
5万
查看次数

ShellEx:启动Excel最小化或隐藏

使用以下代码我可以在C#中运行Excel:

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
p.Start();
Run Code Online (Sandbox Code Playgroud)

我可以使用任何命令行参数使Excel开始隐藏或最小化吗?

(编辑:尝试过p.StartInfo.WindowStyle并且没有效果.)

我需要在不使用COM的情况下启动Excel ,因为在通过COM启动Excel 时,没有加载任何XLA加载项.

c# shell process excel-2007 command-line-arguments

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