OPC Studio User's Guide and Reference
TryParse(String,UABrowsePath) Method
Example 



View with Navigation Tools
OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Navigation.Parsing Namespace > UABrowsePathParser Class : TryParse(String,UABrowsePath) Method
The string containing the absolute browse path to be parsed.

The value of this parameter cannot be null (Nothing in Visual Basic).

OpcLabs.EasyOpc.UA.Navigation.UABrowsePath. If successful, the browse path object corresponding to the input string.

The value of this parameter cannot be null (Nothing in Visual Basic).

Attempts to parse a string containing an absolute browse path.
Syntax
'Declaration
 
<JetBrains.Annotations.CanBeNullAttribute()>
<JetBrains.Annotations.PureAttribute()>
Public Function TryParse( _
   ByVal value As String, _
   ByRef browsePath As UABrowsePath _
) As IStringParsingError
 
'Usage
 
Dim instance As UABrowsePathParser
Dim value As String
Dim browsePath As UABrowsePath
Dim value As IStringParsingError
 
value = instance.TryParse(value, browsePath)

Parameters

value
The string containing the absolute browse path to be parsed.

The value of this parameter cannot be null (Nothing in Visual Basic).

browsePath
OpcLabs.EasyOpc.UA.Navigation.UABrowsePath. If successful, the browse path object corresponding to the input string.

The value of this parameter cannot be null (Nothing in Visual Basic).

Return Value

Returns null if successful; otherwise, some OpcLabs.BaseLib.IStringParsingError indicating the reason of the failure.

This method can return null (Nothing in Visual Basic).

Remarks

This method is pure, i.e. it does not have observable side effects.

Example
// Attempts to parse an absolute OPC-UA browse path and displays its starting node and elements.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.

using System;
using OpcLabs.BaseLib;
using OpcLabs.EasyOpc.UA.Navigation;
using OpcLabs.EasyOpc.UA.Navigation.Parsing;

namespace UACommonDocExamples._UABrowsePathParser
{
    class TryParse
    {
        public static void Main1()
        {
            var browsePathParser = new UABrowsePathParser();

            IStringParsingError stringParsingError = browsePathParser.TryParse(
                "[ObjectsFolder]/Data/Static/UserScalar", 
                out UABrowsePath browsePath);

            // Display results
            if (!(stringParsingError is null))
            {
                Console.WriteLine("*** Error: {0}", stringParsingError);
                return;
            }

            Console.WriteLine("StartingNodeId: {0}", browsePath.StartingNodeId);

            foreach (UABrowsePathElement browsePathElement in browsePath.Elements)
                Console.WriteLine(browsePathElement);

            // Example output:
            // StartingNodeId: ObjectsFolder
            // /Data
            // /Static
            // /UserScalar
        }
    }
}
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also