Видео смотреть бесплатно
Смотреть 2022 видео
Официальный сайт tali-sk 24/7/365
Смотреть видео бесплатно
letter.xsd
and the letter instance is in the file letter.xml
. These two files are reproduced here:<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:letter="http://letterSchema"
targetNamespace="http://letterSchema">
<xsd:element name="letters" type="letter:FormLetter"/>
<xsd:complexType name="FormLetter" mixed="true">
<xsd:sequence>
<xsd:element name="date" minOccurs="0" type="xsd:string"/>
<xsd:element name="firstName" minOccurs="0" type="xsd:string"/>
<xsd:element name="lastName" minOccurs="0" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<letter:letters xmlns:letter="http://letterSchema">
<date>March 1, 2005</date>
Mutual of Omaha
Wild Kingdom, USA
Dear
<firstName>Casy</firstName>
<lastName>Crocodile</lastName>
Please buy more shark repellent.
Your premium is past due.
</letter:letters>
The following example shows how an XML document can be loaded from a file, altered, and written back.
<?php
/**
* Load, update, and save an XML document
*/
try {
$xmldas = SDO_DAS_XML::create("letter.xsd");
$document = $xmldas->loadFile("letter.xml");
$root_data_object = $document->getRootDataObject();
$root_data_object->date = "September 03, 2004";
$root_data_object->firstName = "Anantoju";
$root_data_object->lastName = "Madhu";
$xmldas->saveFile($document, "letter-out.xml");
echo "New file has been written:\n";
print file_get_contents("letter-out.xml");
} catch (SDO_Exception $e) {
print($e->getMessage());
}
?>
An instance of the XML DAS is first obtained from the SDO_DAS_XML::create() method, which is a static method of the SDO_DAS_XML
class. The location of the xsd is passed as a parameter. Once we have an instance of the XML DAS initialised with a given schema, we can use it to load the instance document using the loadFile() method. There is also a loadString() method if you want to load an XML instance document from a string. If the instance document loads successfully, you will be returned an object of type SDO_DAS_XML_Document
, on which you can call the getRootDataObject() method to get the SDO data object which is the root of the SDO data graph. You can then use SDO operations to change the graph. In this example we alter the date
, firstName
, and lastName
properties. Then we use the saveFile() method to write the changed document back to the file system. The saveFile method has an optional extra integer argument which if specified will cause the XML DAS to format the XML, using the integer as the amount to indent by at each change in level on the document.
This will write the following to letter-out.xml
.
Смотреть видео онлайн
Онлайн видео бесплатно