xmlParseDoc

0th

Percentile

Parse an XML document with options controlling the parser.

This function is a generalization of xmlParse that parses an XML document. With this function, we can specify a combination of different options that control the operation of the parser. The options control many different aspects the parsing process

Keywords
data
Usage
xmlParseDoc(file, options = 1L, encoding = character(),
            asText = !file.exists(file), baseURL = file)
Arguments
file

the name of the file or URL or the XML content itself

options

options controlling the behavior of the parser. One specifies the different options as elements of an integer vector. These are then bitwised OR'ed together. The possible options are RECOVER, NOENT, DTDLOAD, DTDATTR, DTDVALID, NOERROR, NOWARNING, PEDANTIC, NOBLANKS, SAX1, XINCLUDE, NONET, NODICT, NSCLEAN, NOCDATA, NOXINNODE, COMPACT, OLD10, NOBASEFIX, HUGE, OLDSAX. ( These options are also listed in the (non-exported) variable parserOptions.)

encoding

character string that provides the encoding of the document if it is not explicitly contained within the document itself.

asText

a logical value indicating whether file is the XML content (TRUE) or the name of a file or URL (FALSE)

baseURL

the base URL used for resolving relative documents, e.g. XIncludes. This is important if file is the actual XML content rather than a URL

Value

An object of class XMLInternalDocument.

References

libxml2

See Also

xmlParse

Aliases
  • xmlParseDoc
  • COMPACT
  • DTDATTR
  • DTDLOAD
  • DTDVALID
  • HUGE
  • NOBASEFIX
  • NOBLANKS
  • NOCDATA
  • NODICT
  • NOENT
  • NOERROR
  • NONET
  • NOWARNING
  • NOXINCNODE
  • NSCLEAN
  • OLDSAX
  • PEDANTIC
  • RECOVER
  • XINCLUDE
  • OLD10
  • SAX1
Examples
# NOT RUN {
 f = system.file("exampleData", "mtcars.xml", package="XML")
     # Same as xmlParse()
 xmlParseDoc(f)

 txt =
     '<top xmlns:r="http://www.r-project.org">
        <b xmlns:r="http://www.r-project.org">
          <c xmlns:omg="http:/www.omegahat.net"/>
        </b>
      </top>'

 xmlParseDoc(txt,  NSCLEAN, asText = TRUE)

 txt =
     '<top xmlns:r="http://www.r-project.org"  xmlns:r="http://www.r-project.org">
        <b xmlns:r="http://www.r-project.org">
          <c xmlns:omg="http:/www.omegahat.net"/>
        </b>
      </top>'

 xmlParseDoc(txt, c(NSCLEAN, NOERROR), asText = TRUE)
# }
Documentation reproduced from package XML, version 3.98-1.19, License: BSD_2_clause + file LICENSE

Community examples

Looks like there are no examples yet.