當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlElement.getOwnerDocument方法代碼示例

本文整理匯總了C#中System.Xml.XmlElement.getOwnerDocument方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlElement.getOwnerDocument方法的具體用法?C# XmlElement.getOwnerDocument怎麽用?C# XmlElement.getOwnerDocument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlElement的用法示例。


在下文中一共展示了XmlElement.getOwnerDocument方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: getDOM

        /*
        ****************************************************************************
        * getDOM()
        ****************************************************************************
        */
        /**
        * This method returns DOM stored with this obj.  It may be cached and
        * there is no guarantee as to which document it was created from
        */
        public XmlElement getDOM()
        {
            if (moElem == null)
            {
            moElem = toDOM(new XmlDocument());
            moElem.getOwnerDocument().AppendChild(moElem);
            }

            return moElem;
        }
開發者ID:AArnott,項目名稱:dotnetxri,代碼行數:19,代碼來源:Assertion.cs

示例2: bestEffortSetIDAttr

        /*
        ****************************************************************************
        * bestEffortSetIDAttr()
        ****************************************************************************
        */
        /**
        * Makes a best effort at setting the ID attribute so that it can be looked
        * up using XmlDocument::getElementsById
        */
        public static void bestEffortSetIDAttr(
        XmlElement oElem, string sNS, string sAttr)
        {
            // do nothing if there is nothing to do
            if ((oElem == null) || (sAttr == null))
            {
            return;
            }

            // if we are using DOM3, use the setIdAttributeNode API
            if (hasDOM3Support())
            {
            Attr oAttr = oElem.getAttributeNodeNS(sNS, sAttr);

            // compiler-friendly way of doing setId as follows:
            // oElem.setIdAttributeNode(oAttr, true);
            try {
                oElem.GetType().getMethod("setIdAttributeNode", new Class[] { oAttr.GetType(), Boolean.TYPE })
                    .invoke(oElem, new Object[] { oAttr, true });
            }
            /*
            catch (IllegalArgumentException e) { }
            catch (SecurityException e) { }
            catch (IllegalAccessException e) { }
            catch (InvocationTargetException e) { }
            catch (NoSuchMethodException e) { }
            */
            catch (Exception e) {
                throw new RuntimeException("Exception caught while calling setIdAttributeNode: " + e);
            }

            if (!oAttr.isId()) {
                throw new RuntimeException("attribute node is not of type Id even after calling setIdAttributeNode!");
            }
            return;
            }

            // if it is an XmlDocument, use the putIdentifier method
            if (isXercesDocument(oElem.getOwnerDocument()))
            {
            string sAttrVal = oElem.getAttributeNS(sNS, sAttr);
            ((XmlDocument) oElem.getOwnerDocument()).putIdentifier(
                sAttrVal, oElem);
            return;
            }

            throw new RuntimeException(
            "No known method to set a signable ID attribute. " +
            "Try using a DOM3-compliant Parser or a DOM2 Xerces XmlDocument.");
        }
開發者ID:AArnott,項目名稱:dotnetxri,代碼行數:59,代碼來源:DOM3Utils.cs


注:本文中的System.Xml.XmlElement.getOwnerDocument方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。