zoukankan      html  css  js  c++  java
  • 使用infopath中的xpath来读取sps中的数据

    在infopath中读取xml数据的时候用selectSingleNode("/信息_/@价格");死活弄不出来,去掉@就没问题了,结果在读sps中的数据的时候就必须用@,xpath的语法也要求用@,但是为什么读xml就不行,真是郁闷

    var selected=XDocument.DOM.selectSingleNode("//my:编号").text;

        objXml 
    = XDocument.GetDOM("(基本信息)");
        
        
    var price = objXml.selectSingleNode("/dfs:myFields/dfs:dataFields/dfs:基本信息_[@编号='"+selected+"']");
       
        
        
    if(price!=null)
        {
            
    if(price.selectSingleNode('@价格')!=null)
            {
            setNodeValue(
    "//my:价格",price.selectSingleNode('@价格').text);
            }
    else
            {
            setNodeValue(
    "//my:价格",'');
            }
    }

      

    读取数据的时候还是抱错,原来少了提取sps数据的命名空间
        XDocument.GetDOM("(基本信息)").setProperty("SelectionNamespaces",'xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');

    同时将提取的数据表示在infopath的文本框中需要:
    function setNodeValue(xpath, value)
    {
        
    var xmlNode = getNode(xpath);

        
    if (!xmlNode)
            
    return;

        
    // The xsi:nil needs to be removed before we set the value.
        if (value != "" && xmlNode.getAttribute("xsi:nil"))
            xmlNode.removeAttribute(
    "xsi:nil");

        
    // Setting the value would mark the document as dirty.
        // Let's do that if the value has really changed.
        if (xmlNode.text != value)
            xmlNode.text 
    = value;
    }
    function getNode(xpath)
    {
        
    // Both XML node and absolute XPath are allowed.
        if (typeof(xpath) == "string")
            
    return XDocument.DOM.selectSingleNode(xpath);
        
    else
            
    return xpath;
    }
  • 相关阅读:
    英飞凌TLE9461V33 SBC芯片
    Lin总线诊断级别定义 CLASS I 、II 、III
    AUTOSAR_SWS_CANInterface 阅读
    AUTOSAR_SWS_CANTransceiverDriver 阅读
    VS2013 快捷键
    Can总线空闲状态时候,TX,RX电平
    postman
    题目2
    Robot Framework 自动化测试
    银行测试 http://blog.csdn.net/stillming/article/details/42275251
  • 原文地址:https://www.cnblogs.com/melonlee/p/210882.html
Copyright © 2011-2022 走看看