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



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Navigation Namespace > UABrowsePath Class > Parse Method : Parse(UABrowsePath,String,String) Method
The base path for relative input paths. A null browse path if none given.

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

The string containing the browse path to be parsed.

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

The namespace URI to be used with all elements that do not explicitly specify a namespace.

The value represents an OPC UA namespace URI string. Any string can be passed to this parameter (i.e. will not cause System.ArgumentException), but not all values make sense and will work when an operation using them is attempted.

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

Parses a string containing a browse path, optionally given a base for relative paths, and returns a corresponding browse path object.
Syntax
'Declaration
 
<NotNullAttribute()>
Public Overloads Shared Function Parse( _
   ByVal basePath As UABrowsePath, _
   ByVal value As String, _
   ByVal defaultNamespaceUriString As String _
) As UABrowsePath
'Usage
 
Dim basePath As UABrowsePath
Dim value As String
Dim defaultNamespaceUriString As String
Dim value As UABrowsePath
 
value = UABrowsePath.Parse(basePath, value, defaultNamespaceUriString)

Parameters

basePath
The base path for relative input paths. A null browse path if none given.

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

value
The string containing the browse path to be parsed.

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

defaultNamespaceUriString
The namespace URI to be used with all elements that do not explicitly specify a namespace.

The value represents an OPC UA namespace URI string. Any string can be passed to this parameter (i.e. will not cause System.ArgumentException), but not all values make sense and will work when an operation using them is attempted.

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

Return Value

Because there is an implicit conversion from UABrowsePath to OpcLabs.EasyOpc.UA.UANodeDescriptor, in languages that support implicit conversion operators (such as C# or VB.NET), you can simply use the returned UABrowsePath in any place where the OpcLabs.EasyOpc.UA.UANodeDescriptor is expected as input, and the corresponding node descriptor will be constructed automatically.

This method never returns null (Nothing in Visual Basic).

Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

Thrown when the OPC UA browse path cannot be parsed.
Remarks
If no base path is given, the input browse path must be absolute.
Example
// This example shows how to read the node using a browse path.
//
// 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.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.Navigation;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    partial class Read
    {
        public static void BrowsePath()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            // Instantiate the client object.
            var client = new EasyUAClient();

            // Create the node descriptor by parsing an absolute browse path.
            // The syntax below specifies a common default namespace URI for the elements of the browse path.
            UANodeDescriptor nodeDescriptor = UABrowsePath.Parse("[ObjectsFolder]/Data/Dynamic/Scalar/FloatValue", "http://test.org/UA/Data/");

            // Alternatively, the namespace URIs can be specified with each element of the browse separately.
            //UANodeDescriptor nodeDescriptor = UABrowsePath.Parse("[ObjectsFolder]/[nsu=http://test.org/UA/Data/;Data]/[nsu=http://test.org/UA/Data/;Dynamic]/[nsu=http://test.org/UA/Data/;Scalar]/[nsu=http://test.org/UA/Data/;FloatValue]", null);
            
            // Alternatively, the namespaces can be specified by indexes, separately with each element.
            //UANodeDescriptor nodeDescriptor = UABrowsePath.Parse("[ObjectsFolder]/2:Data/2:Dynamic/2:Scalar/2:FloatValue", null);

            // Obtain attribute data. By default, the Value attribute of a node will be read.
            UAAttributeData attributeData;
            try
            {
                attributeData = client.Read(endpointDescriptor, nodeDescriptor);
            }
            catch (UAException uaException)
            {
                Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
                return;
            }

            // Display results
            Console.WriteLine($"Value: {attributeData.Value}");
            Console.WriteLine($"ServerTimestamp: {attributeData.ServerTimestamp}");
            Console.WriteLine($"SourceTimestamp: {attributeData.SourceTimestamp}");
            Console.WriteLine($"StatusCode: {attributeData.StatusCode}");
        }
    }
}
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