开发者

Parse a PHP generated (from .xsd template) XML file

I am trying to parse an XML (in Objective-C) file that is generated in PHP from a template, as seen below.

I have tried parsing this with a standard XML parser, but does not seem to load.

What would be the best way to parse this PHP XML generated file? Maybe a 3rd party library?

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:pbu="http://www.something.com/something.xsd" xmlns="http://www.something.com/something.xsd" elementFormDefault="qualified" targetNamespace="http://www.something.com/something.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="app">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="bannerImg" type="xs:anyURI" minOccurs="1" maxOccurs="1" />
            <xs:element name="category" minOccurs="1" maxOccurs="25">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="image" minOccur开发者_Go百科s="1" maxOccurs="40">
                            <xs:complexType>
                                <xs:sequence>
                                    <xs:element name="title" type="xs:string" minOccurs="1" maxOccurs="1" />
                                    <xs:element name="thumbUrl" type="xs:anyURI" minOccurs="1" maxOccurs="1" />
                                    <xs:element name="sampleUrl" type="xs:anyURI" minOccurs="0" maxOccurs="1" />
                                    <xs:element name="imageUrl" type="xs:anyURI" minOccurs="1" maxOccurs="1" />
                                    <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1" />
                                    <xs:element name="infoUrl" type="xs:anyURI" minOccurs="0" maxOccurs="1" />
                                    <xs:element name="license" type="xs:string" minOccurs="1" maxOccurs="1" />
                                    <xs:element name="licenseUrl" type="xs:anyURI" minOccurs="0" maxOccurs="1" />
                                </xs:sequence>
                            </xs:complexType>
                        </xs:element>
                    </xs:sequence>
                    <xs:attribute name="name" type="xs:string" use="required" />
                    <xs:attribute name="icon" type="xs:anyURI" use="required" />
                    <xs:attribute name="unlock_product_id" type="xs:string" use="required" />
                </xs:complexType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="name" type="xs:string" use="required" />
        <xs:attribute name="unlock_product_id" type="xs:string" use="optional" />
    </xs:complexType>
</xs:element>
</xs:schema>


I had to parse an equal structure a few months ago. I didn't try with the xml parser. I did it with TBXML. It's great if you know the structure of the XML file. And it's really well documented. ;-)

Sandro Meier

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜