/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/tag_utils/xml_utils.inc
ViewVC logotype

Annotation of /nfo/php/libs/com.newsblob.phphtmllib/tag_utils/xml_utils.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu Jan 30 03:29:41 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
Branch point for: no_vendor_tag
Initial revision

1 jonen 1.1 <?php
2    
3     /**
4     * This file holds helper functions
5     * for things related to XMLTagClass
6     * objects/data
7     *
8     * $Id: xml_utils.inc,v 1.6 2002/11/01 02:26:14 hemna Exp $
9     *
10     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
11     * @package phpHtmlLib
12     *
13     */
14    
15    
16    
17     /**
18     * This is a simple wrapper function
19     * for building XMLTagClass objects
20     *
21     * @param string - the xml tag name
22     * @param array - the name="value" pairs of
23     * tag attributes
24     * @param mixed - any content that lives in the
25     * PCDATA portion of the XML tag
26     *
27     * @return XMLTagClass object
28     */
29     function xml_tag($name, $attributes=array()) {
30     $tag = new XMLTagClass($name, $attributes);
31     $num_args = func_num_args();
32     for ($i=2;$i<$num_args;$i++) {
33     $tag->add(func_get_arg($i));
34     }
35     return $tag;
36     }
37    
38    
39     /**
40     * This function is used to build a
41     * DOCTYPE tag
42     *
43     * @param string - the document element name (ie. 'HTML')
44     * @param string - the source (ie. 'PUBLIC')
45     * @param string - link 1 (ie. '-//W3C//DTD XHTML 1.0 Transitional//EN' )
46     * @param string - link 2 (ie. 'DTD/xhtml1-transitional.dtd' )
47     *
48     * @return DOCTYPEtag object
49     */
50     function xml_doctype($doc_element, $source="PUBLIC", $link1=NULL, $link2=NULL) {
51    
52     $attributes = array($doc_element, $source);
53    
54     if ($link1 != NULL) {
55     array_push($attributes, "\"". $link1."\"");
56     }
57    
58     if ($link2 != NULL) {
59     array_push($attributes, "\"". $link2."\"");
60     }
61    
62     return new DOCTYPEtag( $attributes );
63     }
64    
65     /**
66     * This function is used to build an
67     * xml-stylesheet tag
68     *
69     * @param string - the href attribute
70     * @param string - the type attribute
71     *
72     * @return XMLSTYLESHEETtag object
73     */
74     function xml_stylesheet( $href, $type="text/css" ) {
75     return new XMLSTYLESHEETtag( array("href" => $href,
76     "type" => $type));
77     }
78    
79    
80    
81     /**
82     * This function converts an array to
83     * an xml document.
84     *
85     * @param array
86     * @param string
87     */
88     function array_to_xml_tree( $arr ) {
89    
90     $xml = container();
91    
92     foreach( $arr as $name => $value) {
93     if (is_array($value)) {
94     $xml->push(xml_tag($name, array(), array_to_xml_tree( $value )));
95     } else {
96     $xml->push(xml_tag( $name, array(), $value ));
97     }
98     }
99     return $xml;
100     }
101    
102    
103     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed