Learn R Programming

XML (version 3.6-2)

getLineNumber: Determine the location - file & line number of an (internal) XML node

Description

The getLineNumber function is used to query the location of an internal/C-level XML node within its original "file". This gives us the line number. getNodeLocation gives both the line number and the name of the file in which the node is located, handling XInclude files in a top-level document and identifying the included file, as appropriate.

This is useful when we identify a node with a particular charactestic and want to view/edit the original document, e.g. when authoring an Docbook article.

Usage

getLineNumber(node, ...)
getNodeLocation(node)

Arguments

node
the node whose location or line number is of interest
...
additional parameters for methods should they be defined.

Value

  • getLineNumber returns an integer. getNodeLocation returns a list with two elements - file and line which are a character string and the integer line number.

concept

XML

References

libxml2

See Also

findXInclude xmlParse getNodeSet xpathApply

Examples

Run this code
f = system.file("exampleData", "xysize.svg", package = "XML")
doc = xmlParse(f)
e = getNodeSet(doc, "//ellipse")
sapply(e, getLineNumber)

Run the code above in your browser using DataLab