I'm looking at PHP to read the XML Schemas and store the veribals and then create some thing like this: -

http://www.o0matte0o.myby.co.uk/project/SVG-UML.htm

So for example if the XML Schema was like this

<xs:element name="note">
    <xs:complexType>
      <xs:sequence>
	<xs:element name="to" type="xs:string"/>
	<xs:element name="from" type="xs:string"/>
	<xs:element name="heading" type="xs:string"/>
	<xs:element name="body" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
</xs:element>
</xs:schema>

So the Image from the link above:-

Example UML Diagram


Atribute 01 : String(30)
Atribute 02 : String(30)
Atribute 03 : String(30)
Atribute 04 : String(30)

The PHP Will Produce the same sorta thing but with the correct atributes.

note


to:string
from:string
heading:string
body:string

Know is this possible with php or should I use a differnet Server Side Coding

    [man]simplexml[/man]
    It's PHP5 only, but it does what you want....

      OK PHP5 is OK as I'm looking at Server Side Coding so if its PHP5 then there is no problem.

      know there is one thing that example is XML, and not XML Schema

      For Example The title of this is Note (xs:element name="note") this need to be stored some where with the sequence elements stored with it as atributes.

      <xs:element name="note">
          <xs:complexType>
            <xs:sequence>
      	<xs:element name="to" type="xs:string"/>
      	<xs:element name="from" type="xs:string"/>
      	<xs:element name="heading" type="xs:string"/>
      	<xs:element name="body" type="xs:string"/>
            </xs:sequence>
          </xs:complexType>
      </xs:element>
      </xs:schema>
      

      the idear of this is for some on to upload the file and the PHP5 read it and produce a image so its not PHP5 with XML inbeded inside.

      the above coding is not XML there differnet
      XML:-

      <note>
          <to>Example Person</to>
          <from>Example Person</from>
          <heading>Example Heading</heading>
          <body>Example Body</body>
      </note>
      

        Thanx for you help but I try to find out how to do this some other place as what I need is a php Script that can Read a XML File not a PHP&XML File

        Example 1
        Submite this to the PHP Script

        <xs:element name="note">
            <xs:complexType>
              <xs:sequence>
        	<xs:element name="to" type="xs:string"/>
        	<xs:element name="from" type="xs:string"/>
        	<xs:element name="heading" type="xs:string"/>
        	<xs:element name="body" type="xs:string"/>
              </xs:sequence>
            </xs:complexType>
        </xs:element>
        </xs:schema>
        

        Will Produce

        note


        to:string
        from:string
        heading:string
        body:string

        But then If I upload anouther XML Schema File it will print off a differnt Set of Information.

        Examlpe 2
        Submite this to the PHP Script

        <xs:element name="Person">
            <xs:complexType>
              <xs:sequence>
        	<xs:element name="Name" type="xs:string"/>
        	<xs:element name="DateOfBirth" type="xs:date"/>
        	<xs:element name="PlaceOfBirth" type="xs:string"/>
        	<xs:element name="Gender" type="xs:string"/>
              </xs:sequence>
            </xs:complexType>
        </xs:element>
        </xs:schema>
        

        Will Produce

        Person


        Name:string
        DateOfBirth:date
        PlaceOfBirth:string
        Gender:string

          hmm... perhaps some basic regex would help. It wouldn't be that hard to come up with... just 3 different patterns...
          Then store it all in an array.... and use that to echo out your information...

            PHP XML parsers will work, including simpleXML, but first you need a valid XML schema. From all you have posted, "<xs:schema>" is closed but not opened, and the "xs" namespace isn't even declared.

              Also note that XML Schemas are themselves written in XML, so anything that can be done to XML documents can be done to XML Schemas (assuming, as dream.scape observes, that the documents are at least well-formed).

              Or are you saying you want to validate an XML document against a given Schema? In which case the [man]DOM[/man] extension provides that functionality.

                The Example code was taken from w3Schools. I'm just using that for example and will be using it to test the script that I will have to code, but it will have to be able to do more complicated Schemas.

                But I need to like I said above is to be able to read the XML Schema and take out the Title and Attributes within the XML Schema and Print them off.
                I dont need to Validate it, I dont need to see if it correct at all. I just need to get the title and Attributes of Each one as Example 1 and Example 2 chould be in the same XML Scheama File but still would have to print out.

                Example

                note


                to:string
                from:string
                heading:string
                body:string
                person: person*

                *Person

                Name:string
                DateOfBirth:date
                PlaceOfBirth:string
                Gender:string[/B]

                * = Shows theres a Link

                  dream.scape wrote:

                  PHP XML parsers will work, including simpleXML,

                  Weedpacket wrote:

                  Also note that XML Schemas are themselves written in XML, so anything that can be done to XML documents can be done to XML Schemas

                  Doesn't that answer your question? Didn't we all answer it? You can do it with simpleXML using the simpleXML->attributes() function. You'll need PHP5 (but you said that's not a problem). Otherwise, you'll need the XML PECL contribution in order to get it going in PHP4.

                    This is Confusing me some what on that page as there is no XML File only Embeded XML in PHP

                    I did see this at the bottom of the page "simplexml_load_file" which looks like it will convert a XML Schema into a php object: -
                    -Am I reading this Correctly?
                    -Will this Die if there is multiply objects in the schema?

                    Interpret an XML document

                    <?php
                    // The file test.xml contains an XML document with a root element
                    // and at least an element /[root]/title.
                    
                    if (file_exists('test.xml')) {
                       $xml = simplexml_load_file('test.xml');
                    
                       var_dump($xml);
                    } else {
                       exit('Failed to open test.xml.');
                    }
                    ?>
                    

                    or would the "simplexml_import_dom" be a better option for this?
                    Also if there is a book that would help me with this can you point out out?

                      What's this "embedded XML in PHP" you keep going on about?

                      Take your own example:

                      o0MattE00 wrote:
                      <?php
                      // The file test.xml contains an XML document with a root element
                      // and at least an element /[root]/title.
                      
                      if (file_exists('test.xml')) {
                         $xml = simplexml_load_file('test.xml');
                      
                         var_dump($xml);
                      } else {
                         exit('Failed to open test.xml.');
                      }
                      ?>

                      This is a PHP file. It does not contain XML.

                      The XML is in the file named "test.xml" (as you can guess from the file extension). It is an XML file. It does not contain PHP.

                        That was taken for a differnet page to the one that every one gave me.
                        example.php

                        <?php
                        $xmlstr = <<<XML
                        <?xml version='1.0' standalone='yes'?>
                        <movies>
                         <movie>
                          <title>PHP: Behind the Parser</title>
                          <characters>
                           <character>
                           <name>Ms. Coder</name>
                           <actor>Onlivia Actora</actor>
                           </character>
                           <character>
                           <name>Mr. Coder</name>
                           <actor>El Act&#211;r</actor>
                           </character>
                          </characters>
                          <plot>
                           So, this language. It's like, a programming language. Or is it a
                           scripting language? All is revealed in this thrilling horror spoof
                           of a documentary.
                          </plot>
                          <rating type="thumbs">7</rating>
                          <rating type="stars">5</rating>
                         </movie>
                        </movies>
                        XML;
                        ?> 
                        

                        php Script

                        <?php
                        include 'example.php';
                        
                        $xml = simplexml_load_string($xmlstr);
                        
                        echo $xml->movie[0]->plot; // "So this language. It's like..."
                        ?> 
                        

                        -----------------------------------------------------------------------------------------------------
                        Any way would the Previous code in the post before read a XML Schema File?

                          Here's what you need to know:
                          simpleXML can read an XML file (with simplexml_load_file()).
                          simpleXML can do what you want with attributes & schema.

                          What you're showing is one possibility in the use of simplexml. It's not even relevant in this case because you want to use an XML file.

                          The reason that PHP may construct XML file(s) or strings is for RSS feeds or other syndication purposes. Or if you use XML in place of a database structure. There's plenty of uses for it. But you keep harping on is that PHP and XML in teh same file. It doens't matter, simpleXML can use an external XML file, it's just a matter of realizing there's a manual with links to other functions similar or within the same class you're looking at.

                          The reason you see it on PHP.net like it is, is because it's easier to reference a string in a given example than to say "as previously declared in our external XML document titled example.xml". It's just for sanity and usability. I'd rather look at an example to guide me to my answer, than look at an example and find what it's referencing every time....

                          What previous code? Which post? There've been 13 (14 including this one). You'd need to use:
                          [man]simplexml_load_file/man
                          [man]simpleXMLElement->attributes/man
                          as well as other functions....

                            Write a Reply...