开发者

Getting XSD content using PHP

I need to extract the content of an XSD file using PHP. I don't want to validate it against an XML; I just need to take some nodes and check some attributes.

Here is my XSD example:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="somelocation.xsd" /> 
  <xsd:complexType name="nameType">
    <xsd:complexContent>
       <xsd:extension base="gml:AbstractFeatureType">
         <xsd:sequen开发者_Go百科ce>
             <xsd:element maxOccurs="1" minOccurs="0" name="x" nillable="true" type="xsd:int" /> 
             <xsd:element maxOccurs="1" minOccurs="0" name="y" nillable="true" type="xsd:int" /> 
             <xsd:element maxOccurs="1" minOccurs="0" name="z" nillable="true" type="xsd:decimal" /> 
         </xsd:sequence>
       </xsd:extension>
  </xsd:complexContent>
  </xsd:complexType>
  <xsd:element name="lz_anual_250" substitutionGroup="gml:_Feature" type="layerType" /> 
</xsd:schema>

I don't know if this is possible, so I'm just asking to an expert on StackOverflow.

Thanks!

PS: I'm using CodeIgniter, so if anyone know any extension or similar to do this, post here please.

EDIT: Problem solved!

Here is a link that could help someone with the same problem as me:

http://www.php.net/manual/en/domdocument.load.php#57911

Simply, someone used DOMXPath class to navigate through the XSD read before using DOMDocument class (like rik told me). The XSD wasn't empty. I was trying to print_r, var_dump and echo the nodes but, obviously there wasn't contain info like a classical XML.


XSD is XML itself. You can work with it like with any XML file.

$doc = new DOMDocument();
$doc->load('your.xsd');
// do whatever you want
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜