Xmldocument class in Delphi (19)-differences between nodevalue and nodename

Source: Internet
Author: User
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, xmldom, xmlintf, msxmldom, xmldoc, stdctrls; Type tform1 = Class (tform) button1: tbutton; xmldocument1: txmldocument; Procedure formcreate (Sender: tobject); Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} procedure tform1.formcreate (Sender: tobject); begin xmldocument1.loadfromfile ('C: \ temp \ test. XML '); {the same return value can be obtained only when an XML test file is provided.} end; Procedure tform1.button1click (Sender: tobject); var node: ixmlnode; begin node: = xmldocument1.documentelement; node: = node. childnodes [0]; {the current node points to the first worker node} // attribute value: nodevalue is a readable showmessage (node. attributenodes [0]. nodevalue); {Section Chief} node. attributenodes [0]. nodevalue: = 'forward length '; showmessage (node. attributenodes [0]. nodevalue); {positive length} // attribute name: nodename is a read-only showmessage (node. attributenodes [0]. nodename); {position} // node. attributenodes [0]. nodename: = 'xxx'; {An error occurred when attempting to assign a value to the attribute name} node: = node. childnodes [0]; {the current node points to the Name node of the first employee "Zhang San"} // node value: nodevalue is a readable showmessage (node. nodevalue); {zhangsan} node. nodevalue: = 'zhang laosan '; showmessage (node. nodevalue); {Zhang laosan} // node name: nodename is a read-only showmessage (node. nodename); {name} // node. nodename: = 'xxx'; {An error occurred while trying to assign a value to the node name} end; end.
 
  
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.