????? ?????? XML ?????? ????? XPathNavigator ???????? Visual Basic

?????? ????????? ?????? ?????????
???? ???????: 301111 - ??? ???????? ???? ????? ????? ??? ???????.
?????? Microsoft Visual C# ?? ??? ??????? ???? 308343.
?????? ??? ????? Microsoft Visual Basic 6.0 ??? ??????? ???? 271619.
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????? ??? ????? ?????? ????????? ??? ??????? (XML) ??????? ?? ???? XPathNavigator ???? ?? ?????? ?? ???? XPathDocument . ??? ?????? ?????? ???? XPathDocument ?? ?????? XML ????? ?????? ???? XPathNavigator ?????? ??? ??? ???????? ????? XML ?????? ?? ???????.

???????

????? ???? ??????? ??????? ??????? ?????? ??? ???????? ??????? ?????? ????????? ???? ??????? ???? ???????:
  • Microsoft Windows Server 2003 ?? ???? ??????? Microsoft Windows 2000 ???????? Windows 2000 Server ? Windows 2000 ????? Server ?? Microsoft ???? ??????? Windows NT 4.0 Server
  • Microsoft Visual Studio 2005 ?? Microsoft Visual Studio .NET
???? ????? ??????? ??? ??????? ??? ???????? ???????:
  • ??????? XML
  • ????? ?????? ????? XML
  • ???? ???? ??? ???? XML (XPath)

????? ??????? ??? XPathNavigator ?????? XML

  1. ?? Visual Studio 2005 ?? ?? Visual Studio. NET? ????? 2005 Visual Basic ?? ????? ???? ??????.net Visual Basic.

    ?????? ?????? ??? ?????? ??? ???? Books.xml. ????? ????? ??? Books.xml ?????? ??? ?? ????? ??????? ????? ???????? ??????.net ????? ????? ?????? (SDK) ?????. ??? ??? ???? ?? ?????? ????? ?????? ???? Books.xml ?? ?????? ??????:
    \Program Files\Microsoft.NET\FrameworkSDK\Samples\Quickstart\Howto\Samples\Xml\Transformxml\VB
    ????? ?? ???? ????? ?????? ??? ??? ????? ?? ???? ????? ???? ??? ??????:
    .aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms762271 (v=vs.85)

    ??? ??? Books.xml ??? ??????\Bin\Debug ??????? ??? ?????? ???? ??? ??????? ??? ???????.
  2. ???? ?? ?? ??????? ????? ????? ????? System.Xml .
  3. ??????? ????? ????????? ??? ?????? Xml ? XPath ??? ??? ?????? ?????? ????????? ?? ?????? ?????? ?? ????????? ???????? ?????? ??. ??? ??????? ????? ????????? ??????? ??? ??????? ??????.
    Imports System.Xml
    Imports System.Xml.XPath
    					
  4. ?? ?????? ????????? ????????. ??????? ????? XPathDocument ???????? ?????? XML ????? XPathNavigator ?????? ??????? XPath ??????? ???????. ?? ?????? ???? String ???????? ?????? XPath. ????? ????????? ???????? ?????? ?? ??????? ??????? ?? ?????? ??????? 1.
    Dim nav As XPathNavigator
    Dim docNav As XPathDocument
    					
  5. ????? ???? XPathDocument ?? ????? ????? Books.xml. ?????? ????? XPathDocument ??????? ??? ????? ??????? ??????? ??????? (XSLT) ?????? ????? ??????? ???? ?????? ??????? ??????? ??????? XML. ????? ????? ???? ??????? XML (DOM) ??? ???? ????? ??????? XSLT ????? ???????? XPath.
    'Open the XML.
    docNav = New XPathDocument("books.xml")
    					
  6. ????? ???? XPathNavigator ?? ???????. ???? ??????? ?????? ??? ????? ?????? XPathNavigator ? ??? ????? ????? ?? ????? XML.
    'Create a navigator to query with XPath.
    nav = docNav.CreateNavigator
    					
  7. ???????? ??? ??? ??????? ???????? ????? ????????? . ????????? ????? ??????? ????? ??????? ???? ????? ??? ???? ???? ?????.
    'Initial XPathNavigator to start at the root.
    nav.MoveToRoot()
    					
  8. ?????? ??????? ??????????????? ???????? ??? ??????? ?????? XML. ???? ??????? ??????????????? ????? ????? ?????? ???????. ?? ?????? ???? Books.xml ???? ????? ?????? ?? ??????? ????? ??? ??????? ??????? ??????? ????? ??? ?????.
    'Move to the first child node (comment field).
    nav.MoveToFirstChild()
    					
  9. ?????? ??????? ??????????? ??????? ???? ????? ??? ????? ????????. ???? ??????? MoveToNext ??? ?????? ?????? ?????? ???????.
    'Loop through all the root nodes.
    Do
        ...
    Loop While nav.MoveToNext
    					
  10. ?????? ??????? NodeType ?????? ?? ?? ??? ??? ?????? ???? ?????? ??????? ???? ??????? ???? ????? ?? ??????.
    Do
        'Find the first element.
        If nav.NodeType = XPathNodeType.Element Then
    'If children exist.
    If nav.HasChildren Then
    
        'Move to the first child.
        nav.MoveToFirstChild()
    
        'Loop through all the children.
        Do
    'Display the data.
    Console.Write("The XML string for this child ")
    Console.WriteLine("is '{0}'", nav.Value)
    Loop While nav.MoveToNext
    
    End If
        End If
    Loop While nav.MoveToNext
    					
  11. ??????? ??????? HasAttributes ?????? ?? ??? ??? ???? ??? ????. ????? ???? ??????? ?????? ???? ??? ???????????????????? ???????? ??? ??? ????? ??????. ???? ?? ??? ???? ????????? ???????? ??? ??? ??????? ?????? ????? ???? ?????? ???????.
    Do
        'Find the first element.
        If nav.NodeType = XPathNodeType.Element Then
    'if children exist
    If nav.HasChildren Then
    
        'Move to the first child.
        nav.MoveToFirstChild()
    
        'Loop through all the children.
        Do
    'Display the data.
    Console.Write("The XML string for this child ")
    Console.WriteLine("is '{0}'", nav.Value)
    
    'Check for attributes.
    If nav.HasAttributes Then
        		Console.WriteLine("This node has attributes")
    End If
    Loop While nav.MoveToNext
    
    End If
        End If
    Loop While nav.MoveToNext
    					
  12. ?????? ??????? ReadLine ?????? ???? ?????? ?????? ????? ???? ?? ????? ??? ???? ?????? ??? ?????? ????? ??? ??????? ???????? ?????.
    'Pause.
    Console.ReadLine()
    					
  13. ????? ?????? ??????? "????? ???? ??????".

????? ??? ????????? ????????

Imports System.Xml
Imports System.Xml.XPath

Module Module1

    Sub Main()
        Dim nav As XPathNavigator
        Dim docNav As XPathDocument
        docNav = New XPathDocument("books.xml")
        nav = docNav.CreateNavigator
        nav.MoveToRoot()
        'Move to the first child node (comment field).
        nav.MoveToFirstChild()

        Do
            'Find the first element.
            If nav.NodeType = XPathNodeType.Element Then
                'if children exist
                If nav.HasChildren Then

                    'Move to the first child.
                    nav.MoveToFirstChild()

                    'Loop through all the children.
                    Do
                        'Display the data.
                        Console.Write("The XML string for this child ")
                        Console.WriteLine("is '{0}'", nav.Value)

                        'Check for attributes.
                        If nav.HasAttributes Then
                            Console.WriteLine("This node has attributes")
                        End If
                    Loop While nav.MoveToNext

                End If
            End If
        Loop While nav.MoveToNext

        'Pause.
        Console.ReadLine()

    End Sub

End Module
				

?????

?? ??? ???? ?? ?????????? ?? ?????? ??? ???? ????? Microsoft (MSDN) ??????? ???????:
XML ??.net: ????.net Framework XML ? C# ???? ?????? ???????? ????? ?????? ???????
http://msdn.microsoft.com/msdnmag/issues/01/01/xml

XPathNavigator ???
http://msdn.microsoft.com/en-us/library/system.xml.xpath.xpathnavigator.aspx

XPathDocument ???
http://msdn.microsoft.com/en-us/library/system.xml.xpath.xpathdocument.aspx

??????? XSLT ?????? XslTransform
http://msdn.microsoft.com/en-us/library/system.xml.xsl.xsltransform.aspx

????? XPath
http://msdn.microsoft.com/en-us/library/ms256086.aspx
?? ??? ???? ?? ?????????? ?? ?????? ???? ??? "????? ???? ??? ????????" (W3C) ???????:
???? XML Path (XPath)
??????? 1.0: ????? W3C 16 ?????? 1999
http://www.w3.org/TR/1999/REC-xpath-19991116

???????

???? ???????: 301111 - ????? ??? ??????: 15/?????/1433 - ??????: 1.0
????? ???
  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET 2003 Standard Edition
  • Microsoft Visual Basic .NET 2002 Standard Edition
????? ??????: 
kbvs2005applies kbvs2005swept kbdownload kbsample kbhowtomaster kbmt KB301111 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????301111

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com