# phpman > perldoc > RDF::Redland::Node

## NAME
    [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown) - Redland RDF Node (RDF Resource, Property, Literal) Class

## SYNOPSIS
      use [RDF::Redland](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland/markdown);
      my $node1=new [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown)("Hello, World!");
      my $node2=new [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown)($uri); # $uri is an [RDF::Redland::URI](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AURI/markdown)
      my $node3=$node2->clone;

      my $node4=new [RDF::Redland::URINode](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AURINode/markdown)("<http://example.com/>");
      my $node5=new [RDF::Redland::LiteralNode](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ALiteralNode/markdown)("Hello, World!");
      my $node6=new [RDF::Redland::XMLLiteral](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AXMLLiteral/markdown)("<tag>content</tag>");
      my $node7=new [RDF::Redland::BlankNode](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ABlankNode/markdown)("genid1");

      # alternate more verbose ways:
      my $node4=[RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown)->new_from_uri("<http://example.com/>");
      my $node5=[RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown)->new_literal("Hello, World!");
      my $node6=[RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown)->new_xml_literal("<tag>content</tag>");
      my $node7=[RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown)->new_from_blank_identifier("genid1");
      ...

      print $node4->uri->as_string,"\n";  # Using [RDF::Redland::URI::as_string](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AURI%3A%3Aasstring/markdown)
      print $node5->literal_value_as_latin1,"\n";

## DESCRIPTION
    This class represents RDF URIs, literals and blank nodes in the RDF graph.

## CONSTRUCTORS
    new [STRING | URI | NODE]
        Create a new URI node, literal node or copy an existing node.

        If a literal *STRING* is given, make a plain literal node. If a the argument is of type
        *URI* (perl URI or [RDF::Redland::URI](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AURI/markdown)), make a resource node.

        Otherwise if the argument is an [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown) *NODE*, copy it.

    new_from_uri URI
        Create a new URI node. *URI* can be either a [RDF::Redland::URI](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AURI/markdown) object, a perl URI class or a
        literal string.

        An alternative is:

          new [RDF::Redland::URINode](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AURINode/markdown)("<http://example.org/>");

    new_literal STRING [DATATYPE [XML_LANGUAGE]]
        Create a new literal node for a literal value *STRING*. Optional datatype URI *DATATYPE*
        ([RDF::Redland::URI](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AURI/markdown), perl URI or string) and language (xml:lang attribute) *XML_LANGUAGE* may
        also be given.

        An alternative is:

           new [RDF::Redland::LiteralNode](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ALiteralNode/markdown)("Hello, World!");
           new [RDF::Redland::LiteralNode](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ALiteralNode/markdown)("Bonjour monde!", undef, "fr");

    new_xml_literal STRING
        Create a new XML datatyped literal node for the XML in *STRING*.

        An alternative is:

          new [RDF::Redland::XMLLiteral](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AXMLLiteral/markdown)("<tag>content</tag>");

    new_from_blank_identifier IDENTIFIER
        Create a new blank node with blank node identifier *IDENTIFIER*.

        An alternative is:

          new [RDF::Redland::BlankNode](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ABlankNode/markdown)("id");

    clone
        Copy a [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown).

## METHODS
    uri Get the current URI of the node as an [RDF::Redland::URI](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AURI/markdown) object.

    blank_identifier
        Get the current blank identifier of the node

    type
        Get the node type. It is recommended to use the is_resource, is_literal or is_blank methods
        in preference to this (both simpler and quicker).

        The current list of types that are supported are:

          $[RDF::Redland::Node::Type_Resource](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode%3A%3ATypeResource/markdown)
          $[RDF::Redland::Node::Type_Literal](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode%3A%3ATypeLiteral/markdown)
          $[RDF::Redland::Node::Type_Blank](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode%3A%3ATypeBlank/markdown)

        Example:

          if ($node->type == $[RDF::Redland::Node::Type_Resource](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode%3A%3ATypeResource/markdown)) {
            print "Node is a resource with URI ", $node->uri->as_string, "\n";
          } else {
            ...
          }

    is_resource
        Return true if node is a resource (with a URI)

    is_literal
        Return true if node is a literal

    is_blank
        Return true if node is a blank nodeID

    literal_value
        Get the node literal value string as UTF-8 (when the node is of type
        $[RDF::Redland::Node::Type_Literal](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode%3A%3ATypeLiteral/markdown))

    literal_value_as_latin1
        Get the node literal value string converted from UTF-8 to ISO Latin-1 (when the node is of
        type $[RDF::Redland::Node::Type_Literal](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode%3A%3ATypeLiteral/markdown))

    literal_value_language
        Get the node literal XML language (when the node is of type
        $[RDF::Redland::Node::Type_Literal](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode%3A%3ATypeLiteral/markdown)) or undef if not present.

    literal_value_is_wf_xml
        Return non 0 if the literal string is well formed XML (when the node is of type
        $[RDF::Redland::Node::Type_Literal](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode%3A%3ATypeLiteral/markdown)).

    literal_datatype
        Return the [RDF::Redland::URI](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AURI/markdown) of the literal datatype or undef if it is not a datatype.

    as_string
        Return the [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown) formatted as a string (UTF-8 encoded).

    equals NODE
        Return non zero if this node is equal to NODE

## OLDER METHODS
    new_from_literal STRING XML_LANGUAGE IS_WF
        Create a new [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown) object for a literal value *STRING* with XML language
        (xml:lang attribute) *XML_LANGUAGE* and if content is well formed XML, when *IS_WF* is non
        0. *XML_LANGUAGE* is optional can can be set to undef.

        This method remains but using new_literal is preferred. Instead, for plain literals use:

          $node=new [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown)("blah")

    new_from_typed_literal STRING [DATATYPE [XML_LANGUAGE]]
        Renamed to new_literal with same arguments.

    new_from_uri_string URI_STRING
        Create a new [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown) object for a resource with URI *URI_STRING*. It is
        equivalent to use the shorter:

          $a=new [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown)->new_from_uri($uri_string)

    new_from_node NODE
        Create a new [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown) object from existing [RDF::Redland::Node](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3ANode/markdown) *NODE* (copy
        constructor). It is equivalent to use:

          $new_node=$old_node->clone

## SEE ALSO
    [RDF::Redland::Statement](https://www.chedong.com/phpMan.php/perldoc/RDF%3A%3ARedland%3A%3AStatement/markdown)

## AUTHOR
    Dave Beckett - <http://www.dajobe.org/>

