CSharpTest.Net
ParseAttributes Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightParser Class : ParseAttributes Method

tagXml

Glossary Item Box

Returns an enumeration of attribute name/value pairs from within an element: <elem attr="value">

Syntax

Visual Basic (Declaration) 
Public Shared Function ParseAttributes( _
   ByVal tagXml As String _
) As IEnumerable(Of XmlLightAttribute)
C# 
public static IEnumerable<XmlLightAttribute> ParseAttributes( 
   string tagXml
)

Parameters

tagXml

Example

Library/Library.Test/TestHtmlParser.cs

C#Copy Code
IEnumerator<XmlLightAttribute> en;
en = XmlLightParser.ParseAttributes("<tag a=\"1\" b='2' c=3 d e=>").GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("a", en.Current.Name);
Assert.AreEqual("1", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("b", en.Current.Name);
Assert.AreEqual("2", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("c", en.Current.Name);
Assert.AreEqual("3", en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("d", en.Current.Name);
Assert.AreEqual(null, en.Current.Value);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("e", en.Current.Name);
Assert.AreEqual("", en.Current.Value);
Assert.IsFalse(en.MoveNext());

en = XmlLightParser.ParseAttributes("<?xml version='1.0'?>").GetEnumerator();
Assert.IsTrue(en.MoveNext());
Assert.AreEqual("version", en.Current.Name);
Assert.AreEqual("1.0", en.Current.Value);
Assert.IsFalse(en.MoveNext());
VB.NETCopy Code
Dim en As IEnumerator(Of XmlLightAttribute)
en = XmlLightParser.ParseAttributes("<tag a=""1"" b='2' c=3 d e=>").GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("a", en.Current.Name)
Assert.AreEqual("1", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("b", en.Current.Name)
Assert.AreEqual("2", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("c", en.Current.Name)
Assert.AreEqual("3", en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("d", en.Current.Name)
Assert.AreEqual(Nothing, en.Current.Value)
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("e", en.Current.Name)
Assert.AreEqual("", en.Current.Value)
Assert.IsFalse(en.MoveNext())

en = XmlLightParser.ParseAttributes("<?xml version='1.0'?>").GetEnumerator()
Assert.IsTrue(en.MoveNext())
Assert.AreEqual("version", en.Current.Name)
Assert.AreEqual("1.0", en.Current.Value)
Assert.IsFalse(en.MoveNext())

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys