Moodle PHP Documentation 4.1
Moodle 4.1.19+ (Build: 20250711) (5f47dc23ffc)
PhpXmlRpc\Helper\XMLParser Class Reference

Public Member Functions

 __construct (array $options=array())
 
 parse ($data, $returnType=self::RETURN_XMLRPCVALS, $accept=3, $options=array())
 
 xmlrpc_cd ($parser, $data)
 xml parser handler function for character data.
 
 xmlrpc_dh ($parser, $data)
 xml parser handler function for 'other stuff', ie.
 
 xmlrpc_ee ($parser, $name, $rebuildXmlrpcvals=1)
 xml parser handler function for close element tags.
 
 xmlrpc_ee_epi ($parser, $name)
 Used in decoding xmlrpc requests/responses while building xmlrpc-extension Values (plain php for all but base64 and datetime).
 
 xmlrpc_ee_fast ($parser, $name)
 Used in decoding xmlrpc requests/responses without rebuilding xmlrpc Values.
 
 xmlrpc_se ($parser, $name, $attrs, $acceptSingleVals=false)
 xml parser handler function for opening element tags.
 
 xmlrpc_se_any ($parser, $name, $attrs)
 xml parser handler function for opening element tags.
 

Static Public Member Functions

static guessEncoding ($httpHeader='', $xmlChunk='', $encodingPrefs=null)
 xml charset encoding guessing helper function.
 

Public Attributes

 $_xh
 
 $xmlrpc_valid_parents
 
const ACCEPT_FAULT = 8
 
const ACCEPT_REQUEST = 1
 
const ACCEPT_RESPONSE = 2
 
const ACCEPT_VALUE = 4
 
const RETURN_EPIVALS = 'epivals'
 
const RETURN_PHP = 'phpvals'
 
const RETURN_XMLRPCVALS = 'xmlrpcvals'
 

Protected Attributes

int $accept = 3
 $accept self::ACCEPT_REQUEST | self::ACCEPT_RESPONSE by default
 
int $maxChunkLength = 4194304
 $maxChunkLength 4 MB by default.
 
array $parsing_options = array()
 $parsing_options
 

Constructor & Destructor Documentation

◆ __construct()

PhpXmlRpc\Helper\XMLParser::__construct ( array $options = array())
Parameters
array$optionspassed to the xml parser

Member Function Documentation

◆ guessEncoding()

static PhpXmlRpc\Helper\XMLParser::guessEncoding ( $httpHeader = '',
$xmlChunk = '',
$encodingPrefs = null )
static

xml charset encoding guessing helper function.

Tries to determine the charset encoding of an XML chunk received over HTTP. NB: according to the spec (RFC 3023), if text/xml content-type is received over HTTP without a content-type, we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of non conforming (legacy?) clients/servers, which will be most probably using UTF-8 anyway... In order of importance checks:

  1. http headers
  2. BOM
  3. XML declaration
  4. guesses using mb_detect_encoding()
Parameters
string$httpHeaderthe http Content-type header
string$xmlChunkxml content buffer
string$encodingPrefscomma separated list of character encodings to be used as default (when mb extension is enabled). This can also be set globally using PhpXmlRpc::$xmlrpc_detectencodings
Return values
stringthe encoding determined. Null if it can't be determined and mbstring is enabled, PhpXmlRpc::$xmlrpc_defencoding if it can't be determined and mbstring is not enabled
Todo
explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!!

◆ parse()

PhpXmlRpc\Helper\XMLParser::parse ( $data,
$returnType = self::RETURN_XMLRPCVALS,
$accept = 3,
$options = array() )
Parameters
string$data
string$returnType
int$accepta bit-combination of self::ACCEPT_REQUEST, self::ACCEPT_RESPONSE, self::ACCEPT_VALUE
array$options

◆ xmlrpc_dh()

PhpXmlRpc\Helper\XMLParser::xmlrpc_dh ( $parser,
$data )

xml parser handler function for 'other stuff', ie.

not char data or element start/end tag. In fact it only gets called on unknown entities...

◆ xmlrpc_se_any()

PhpXmlRpc\Helper\XMLParser::xmlrpc_se_any ( $parser,
$name,
$attrs )

xml parser handler function for opening element tags.

Used in decoding xml chunks that might represent single xmlrpc values as well as requests, responses.

Deprecated
Parameters
resource$parser
$name
$attrs

Member Data Documentation

◆ $_xh

PhpXmlRpc\Helper\XMLParser::$_xh
Initial value:
'ac' => '',
'stack' => array(),
'valuestack' => array(),
'isf' => 0,
'isf_reason' => '',
'value' => null,
'method' => false,
'params' => array(),
'pt' => array(),
'rt' => '',
)
('')  

◆ $maxChunkLength

int PhpXmlRpc\Helper\XMLParser::$maxChunkLength = 4194304
protected

$maxChunkLength 4 MB by default.

Any value below 10MB should be good

◆ $xmlrpc_valid_parents

PhpXmlRpc\Helper\XMLParser::$xmlrpc_valid_parents
Initial value:
'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
'BOOLEAN' => array('VALUE'),
'I4' => array('VALUE'),
'I8' => array('VALUE'),
'EX:I8' => array('VALUE'),
'INT' => array('VALUE'),
'STRING' => array('VALUE'),
'DOUBLE' => array('VALUE'),
'DATETIME.ISO8601' => array('VALUE'),
'BASE64' => array('VALUE'),
'MEMBER' => array('STRUCT'),
'NAME' => array('MEMBER'),
'DATA' => array('ARRAY'),
'ARRAY' => array('VALUE'),
'STRUCT' => array('VALUE'),
'PARAM' => array('PARAMS'),
'METHODNAME' => array('METHODCALL'),
'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
'FAULT' => array('METHODRESPONSE'),
'NIL' => array('VALUE'),
'EX:NIL' => array('VALUE'),
)

The documentation for this class was generated from the following file: