2

How to parse a document like the one shown below?

<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'
xmlns:rs='urn:schemas-microsoft-com:rowset'
xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
<s:ElementType name='row' content='eltOnly'>
       <s:AttributeType name='StMovement' rs:number='1' rs:nullable='true' rs:writeunknown='true'>
        <s:datatype dt:type='number' rs:dbtype='numeric' dt:maxLength='19' rs:scale='0' rs:precision='28' rs:fixedlength='true'/>
    </s:AttributeType>
    </s:ElementType>
</s:Schema>

<rs:data>
<z:row StMovement='21123'/>
</rs:data>

I know that there is something like .children(<schemaurl>), but this only works if there is an xsd at some URL.

0

1 Answer 1

1

See the documentation for the ->children() method. Namespace identifiers do not have to point at an XSD in order to be used in this way, you just need to know the URI string to pass in.

You can also set the second parameter of that method to true and use the local alias/prefix for the namespace, which is theoretically less reliable, but usually fine in practice.

In your case (if you add the </xml>, which is missing in your sample above) both of the following will work fine:

echo (string)$sx->children('uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882')->Schema->attributes()->id;
echo (string)$sx->children('s', true)->Schema->attributes()->id;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.