Archive

Posts Tagged ‘xml’

RSS(XML) reading process

October 31, 2007 1 comment

$this->parser = xml_parser_create();
if(is_resource($this->parser)){
xml_set_object($this->parser, &$this);
xml_set_element_handler($this->parser, ‘feed_start_element’, ‘feed_end_element’);
xml_set_character_data_handler( $this->parser, ‘feed_cdata’ );
return true;
}
return false;

xml_parser_create
(PHP 3>= 3.0.6, PHP 4 , PHP 5)
xml_parser_create — Create an XML parser

Description

resource xml_parser_create ( [string encoding])

xml_parser_create()
creates a new XML parser and returns a resource handle referencing it to be used by the other XML functions.

xml_parser_create()는 파서를 생성하고,
관련된 xml 관련 함수의 리소스 핸들러를 사용.
이 옵션은 XML 입력시 파서의 문자 엔코딩을 알아내기 위한 옵션.
ISO-8859-1 기반인 UTF-8, US-ASCII 등을 사용할 수 있다.

The optional encoding specifies the character encoding of the XML input to be parsed.
Supported encodings are “ISO-8859-1″, which is also the default if no encoding is specified,
“UTF-8″ and “US-ASCII”.

is_resource
(PHP 4, PHP 5)
is_resource — Finds whether a variable is a resource

Description

bool is_resource ( mixed $var )
Finds whether the given variable is a resource.

is_resource()은
var 인자에 주어진 변수가 resource면 TRUE를,
아니라면 FALSE를 반환.

Parameters
var
The variable being evaluated.

Return Values
Returns TRUE if var is a resource, FALSE otherwise.

xml_set_object
(PHP 4 , PHP 5)
xml_set_object — Use XML Parser within an object

Description

void xml_set_object ( resource parser, object object)

This function allows to use parser inside object.
All callback functions could be set with xml_set_element_handler() etc and assumed to be methods of object.

xml_set_element_handler
(PHP 3>= 3.0.6, PHP 4 , PHP 5)
xml_set_element_handler — Set up start and end element handlers

Description

bool xml_set_element_handler
( resource parser, callback start_element_handler, callback end_element_handler)

Sets the element handler functions for the XML parser parser.
start_element_handler and end_element_handler are strings containing the names of functions that must exist when xml_parse() is called for parser.

The function named by start_element_handler must accept three parameters:
start_element_handler ( resource parser, string name, array attribs)

parser
The first parameter, parser, is a reference to the XML parser calling the handler.

name
The second parameter, name, contains the name of the element for which this handler is called.
If case-folding is in effect for this parser, the element name will be in uppercase letters.

attribs
The third parameter, attribs, contains an associative array with the element’s attributes (if any).
The keys of this array are the attribute names, the values are the attribute values.
Attribute names are case-folded on the same criteria as element names.
Attribute values are not case-folded.

The original order of the attributes can be retrieved by walking through attribs the normal way,
using each().
The first key in the array was the first attribute, and so on.

The function named by end_element_handler must accept two parameters:
end_element_handler ( resource parser, string name)

parser
The first parameter, parser, is a reference to the XML parser calling the handler.

name
The second parameter, name, contains the name of the element for which this handler is called.
If case-folding is in effect for this parser, the element name will be in uppercase letters.

If a handler function is set to an empty string, or FALSE, the handler in question is disabled.
TRUE is returned if the handlers are set up, FALSE if parser is not a parser.

xml_set_character_data_handler
(PHP 3>= 3.0.6, PHP 4 , PHP 5)
xml_set_character_data_handler — Set up character data handler

Description

bool xml_set_character_data_handler
( resource parser, callback handler)

Sets the character data handler function for the XML parser parser.
handler is a string containing the name of a function that must exist when xml_parse() is called for parser.

The function named by handler must accept two parameters:
handler ( resource parser, string data)

parser
The first parameter, parser, is a reference to the XML parser calling the handler.

data
The second parameter, data, contains the character data as a string.

If a handler function is set to an empty string, or FALSE, the handler in question is disabled.

When send a TrackBack Ping

October 1, 2007 2 comments

The possible parameters in the request content are the following:

  • title : The title of the entry. Optional.
  • excerpt : An excerpt of the entry. Optional.
  • url : The permalink for the entry.  Like any permalink, this should point as closely as possible to the actual entry on the HTML page, as it will be used when linking to the entry in question. Required. If a client neglects to send a url, the server MUST respond with an error message.
  • blog_name : The name of the weblog to which the entry was posted. Optional.

All parameters is POST format.

To send a ping, the client sends an HTTP POST request to the TrackBack Ping URL.

The client MUST send a Content-Type HTTP header, with the content type set to application/x-www-form-urlencoded.

The client should include the character encoding of the content being sent (title, excerpt, and weblog name) in the charset attribute of the Content-Type header.

Source links

      Tags: ,

      Links about Atom format

      September 15, 2007 Leave a comment
      Tags: ,