简体   繁体   中英

How can I validate a XML file?

my contacts.xml file is:

<?xml version="1.1" encoding="UTF-8" standalone="no" ?>
 <Directory>
   <Contacts DeviceID="" FolderID="" FolderName="">    
      <Contact contacttype="0" id="111" optype="0">
         <FirstName>shiva1</FirstName>
         <wsuniqueid>00000000A4DACC2711A8D24C9AC2C2999311125BC4306A00</wsuniqueid>
      </Contact>
      <Contact contacttype="0" id="222" optype="0">
         <FirstName>shiva2</FirstName>
         <wsuniqueid>00000000A4DACC2711A8D24C9AC2C2999311125BC4306A01</wsuniqueid>
      </Contact>
   </Contacts>
</Directory>

when i want to insert some node or data by query:

insert node <a/> into doc('contacts.xml')//Directory/Contacts/Contact[@id = '111'] 

from linux command it is giving error XQDY0084 ..

The error code is not related to the insertion (directly). It indicated you are using strict validation somewhere, and you are not adhering to the strict validation rules. Perhaps because the system cannot find an appropriate schema file in which Directory is a valid root element.

Namespace your elements, and use an appropriate XML Schema, or decide not to validate at all.

HTH!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM