コード例 #1
0
ファイル: XmlUtils.cs プロジェクト: rubitek/OpenADK-csharp
        public static XmlElement GetElementByAttribute(XmlElement parent,
                                                       string elementName,
                                                       string attributeName,
                                                       string attributeValue,
                                                       bool filtered)
        {
            if (parent == null || elementName == null || attributeName == null ||
                attributeValue == null)
            {
                return(null);
            }
            // TODO: Implement better filtering in the xpath expression so that the multiple steps of operations are not necessary
            XmlElement element = null;
            string     xPath   = elementName + "[@" + attributeName + "=\"" + attributeValue + "\"]";

            if (filtered)
            {
                FilteredElementList list       = new FilteredElementList(parent.SelectNodes(xPath));
                IEnumerator         enumerator = list.GetEnumerator();
                if (enumerator.MoveNext())
                {
                    element = (XmlElement)enumerator.Current;
                }
            }
            else
            {
                element = (XmlElement)parent.SelectSingleNode(xPath);
            }
            return(element);
        }
コード例 #2
0
ファイル: XmlUtils.cs プロジェクト: rafidzal/OpenADK-csharp
 public static XmlElement GetElementByAttribute( XmlElement parent,
                                                 string elementName,
                                                 string attributeName,
                                                 string attributeValue,
                                                 bool filtered )
 {
     if ( parent == null || elementName == null || attributeName == null ||
          attributeValue == null ) {
         return null;
     }
     // TODO: Implement better filtering in the xpath expression so that the multiple steps of operations are not necessary
     XmlElement element = null;
     string xPath = elementName + "[@" + attributeName + "=\"" + attributeValue + "\"]";
     if ( filtered ) {
         FilteredElementList list = new FilteredElementList( parent.SelectNodes( xPath ) );
         IEnumerator enumerator = list.GetEnumerator();
         if ( enumerator.MoveNext() ) {
             element = (XmlElement) enumerator.Current;
         }
     }
     else {
         element = (XmlElement) parent.SelectSingleNode( xPath );
     }
     return element;
 }
コード例 #3
0
ファイル: XmlUtils.cs プロジェクト: rafidzal/OpenADK-csharp
 /// <summary>
 /// Builds an array of XmlElements from an XmlNodeList
 /// </summary>
 /// <param name="list">an XmlNodeList</param>
 /// <param name="filter">If true, returns only the elements with an "enabled" property set to "True" or "Yes"</param>
 /// <returns>the array of elements</returns>
 /// <remarks>
 /// If there are no elements in the list or that are enabled, an empty array will be returned
 /// </remarks>
 public static XmlElement[] ElementArrayFromNodeList( XmlNodeList list,
                                                       bool filter )
 {
     ArrayList v = new ArrayList();
     IEnumerator enumerator;
     if ( filter ) {
         enumerator = new FilteredElementList( list ).GetEnumerator();
     }
     else {
         enumerator = list.GetEnumerator();
     }
     while ( enumerator.MoveNext() ) {
         v.Add( enumerator.Current );
     }
     return (XmlElement []) v.ToArray( typeof ( XmlElement ) );
 }
コード例 #4
0
ファイル: XmlUtils.cs プロジェクト: rubitek/OpenADK-csharp
        /// <summary>
        /// Builds an array of XmlElements from an XmlNodeList
        /// </summary>
        /// <param name="list">an XmlNodeList</param>
        /// <param name="filter">If true, returns only the elements with an "enabled" property set to "True" or "Yes"</param>
        /// <returns>the array of elements</returns>
        /// <remarks>
        /// If there are no elements in the list or that are enabled, an empty array will be returned
        /// </remarks>
        public static XmlElement [] ElementArrayFromNodeList(XmlNodeList list,
                                                             bool filter)
        {
            ArrayList   v = new ArrayList();
            IEnumerator enumerator;

            if (filter)
            {
                enumerator = new FilteredElementList(list).GetEnumerator();
            }
            else
            {
                enumerator = list.GetEnumerator();
            }
            while (enumerator.MoveNext())
            {
                v.Add(enumerator.Current);
            }
            return((XmlElement [])v.ToArray(typeof(XmlElement)));
        }