小编Sof*_*ant的帖子

XmlDocument并使用xPath获取特定属性

我在这里看到了几个例子,其中Xpath与XmlDocument一起使用,以从XmlDocument节点获取特定属性....

Console.WriteLine(xmlDocument.SelectSingleNode("//dataTemplateSpecification/templates/template/elements/element/@name").Value.ToString());
Run Code Online (Sandbox Code Playgroud)

出于某种原因,我得到一个"对象引用未设置为对象的实例".例外.每当我遇到特定的代码行时.我有一个小测试应用程序,我已经设置为测试不同的东西,然后我把它们放入我的主项目...

这是代码......

namespace ReadXml
{
    class Program
    {
        static void Main(string[] args)
        {
            //string fulXmlPath =     System.Web.Hosting.HostingEnvironment.MapPath("~/App_Data/templateExample.xml");
            XDocument xDocument = XDocument.Load("C:\\Users\\derekww\\Documents\\XML Documents\\templateExample.xml");
            XElement elem = xDocument.Element("dataTemplateSpecification"); ;
            XmlDocument xmlDocument = new XmlDocument();
            StreamReader file = new StreamReader("C:\\Users\\derekww\\Documents\\XML Documents\\templateExample.xml");

            xmlDocument.Load(file);

            //XmlDocument theDoc = new XmlDocument();
            //using (var xmlReader = xDocument.CreateReader())
            //{
            //    xmlDocument.Load(xmlReader);
            //}

            //Console.WriteLine(elem.ToString());
            XmlNode xNode = xmlDocument.SelectSingleNode("//dataTemplateSpecification/templates/template/elements/element");
            Console.WriteLine("WORK PLEASE!!!! {0}", xNode.Value.ToString());
            //Console.WriteLine(xmlDocument.SelectSingleNode("//dataTemplateSpecification/templates/template/elements/element/@name").Value.ToString());
            //Console.WriteLine("This better Work>>>> {0}", xmlDocument.Attributes["/dataTemplateSpecification/templates/template/elements/element/@name"].Value);
            Console.ReadLine();
            //Console.WriteLine("This better Work>>>> {0}", xmlDocument.SelectSingleNode("//dataTemplateSpecification/templates/template/elements/element/@name").Value);
            //foreach (String AttVal in …
Run Code Online (Sandbox Code Playgroud)

c# xml xpath xmldocument xml-attribute

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

使用Linq列表时没有获得不同的项目?

这是我试图获得一个独特的项目列表...

    var queryResults = PatientList.Distinct();
    PatientList = queryResults.ToList<SelectListItem>();
Run Code Online (Sandbox Code Playgroud)

出于某种原因,我在这里没有得到明确的清单.

c# linq

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

使用不同的参数多次执行SQL查询

我有一个SQL存储过程,我需要使用不同的参数执行几次.是否可以执行某种类型的SQL脚本,它会像数组或其他不同参数的数据结构一样多次执行?有什么想法吗?

sql-server sql-scripts

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

发布MVC 4应用程序异常..,指定的路径,文件名或两者都太长

我正在尝试使用文件系统方法发布网站.我在visual studio 2010中使用了这种方法,并没有遇到很多问题.但是我在visual studio 2012中尝试时收到了上述错误.完整的错误如下...

Error : Copying file Service References\ACOServiceReference\FocusedReadMissionsRedux.ACOServiceReference.searchPatientbyDemographicsResponse.datasource to obj\Release\Package\PackageTmp\Service References\ACOServiceReference\FocusedReadMissionsRedux.ACOServiceReference.searchPatientbyDemographicsResponse.datasource failed. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Run Code Online (Sandbox Code Playgroud)

我错过了什么或做错了什么?显然文件路径太长了,但有没有办法可以创建路径变量或缩短路径名?我怎么设置它?

publish-subscribe visual-studio-2012

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

Jquery Datepicker和Jquery验证

我想知道,如何将我的jquery验证消息移动到日期选择器图标的右侧?有什么我可以在CSS中做,或者有一些我可以以某种方式放置标签.真的很困惑.

目前,验证消息在发生验证错误时将我的datepicker图像推向右侧.我希望该消息在右侧,因此datepicker图像保持不变.

validation jquery datepicker

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

在C#中是否存在空日期

我想在Oracle数据库中输入日期.有时这个值将为null.所以在我写的函数中,我需要一种方法来传递这个null值.我在这个日期作为存储过程的参数传递.此参数可以为null.我正在使用Oracle.DataAccess dll来使这个东西工作.如果它确实为null,我想只是抛出一个null变量.你觉得那会有用吗??? 以下是我目前正在设置此方案的方式......

cmd.Parameters.Add("ACTIVE_DATEIn", DateTime.Parse(ActiveDate));
conn.Open();
outcome = cmd.ExecuteNonQuery();
Run Code Online (Sandbox Code Playgroud)

活动日期是我要传入的可能的空变量.显然,您无法将空值转换为日期时间.你们会建议做什么?

oracle variables nullable c#-4.0

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

不在我的XSLT中添加新行

我不确定为什么我的xslt不会在我的输出中添加新行...这是我的xslt ....

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="text" encoding="iso-8859-1"/>
  <xsl:variable name="newline"></xsl:variable>
  <xsl:template name="FairWarningTransform" match="/">    <!--@* | node()">-->

          <xsl:for-each select="//SelectFairWarningInformationResult">  

                <xsl:value-of select="ApplicationID"/>,<xsl:value-of select="USERID"/>
                &#10;
          </xsl:for-each>

        * Note.  This report outlines Fair warning entries into reported for the above time frame.

      </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

这是我的输出......

1,TEST1,test2,
Run Code Online (Sandbox Code Playgroud)

我希望它看起来像......

1,TEST
1,test2,
Run Code Online (Sandbox Code Playgroud)

为什么这个角色不能创建换行符

xslt newline

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

解析文本文件并将内容放入数组 Powershell

我正在寻找一种方法来解析文本文件并将结果放入 powershell 中的数组中。

我知道 select-string -path -pattern 将获取与模式匹配的所有字符串。但是,如果我已经有一个结构化文本文件,可能是管道分隔的,并且每行都有新条目,该怎么办?就像这样:

prodServ1a prodServ1b prodServ1c

C:\dir\serverFile.txt

如何将每台服务器放入 powershell 中的一个可以循环访问的数组中?

text-files powershell-2.0

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

在Oracle中选择DISTINCT或UNIQUE记录或行

我想从我查询的数据库中选择不同或唯一的记录.我怎么能这样做,但同时选择整个记录而不仅仅是我区分为独特的列?我必须做不守规矩的连接吗?

sql unique distinct

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

在Java中向方法调用添加未知数量的参数

我有一个方法,我想扩展(而不是编写一个基本相同的新方法),通过在参数列表的末尾添加未知数量的参数.

如果我这样做,我是否必须更改对该方法的所有调用?我想问题是,未知参数是否包括根本没有传入参数的情况?

例如,如果我有一个方法:

queryFactory(int [] typeArgs, int queryType, int[] ... args){}
Run Code Online (Sandbox Code Playgroud)

我可以打电话:

queryFactory(typeArgsInstce, queryTypeInstce)
Run Code Online (Sandbox Code Playgroud)

然后,当我需要向查询调用添加参数时:

queryFactory(typeArgsInstce, queryTypeInstce, argsInstce)
Run Code Online (Sandbox Code Playgroud)

argsInstce包含额外参数的整数数组在哪里.

我想编辑这个方法,而不是编写一个几乎完全相同的新方法,除了它有一些参数添加到查询.我将简单地编写另一种方法,如果通过编辑这个方法,我将不得不改变对该方法的所有其他调用.

java argument-passing

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