In this section, let's learn the entity, in the object-oriented programming process, often encounter the concept of entities. For example, user entities, then we say that the user entity refers to a user with some attribute values.
In fact, the concept of XML is also almost.
The entities in XML include two types: general entities and parameter entities.
Generally, the letter signed by us, the letter is the general entity. The format that defines the general entity is as follows:
The entity of the letter signed upon just now is as follows:
>
Also, you can also specify an entity instead of an external file, you want to use the System this keyword. E.g:
In this example, the XML processor will replace the entity instruction with the contents of the specified file.
Parameter entity
As with the general entity, the parameter entity may be both internal or external. However, the parameter entity is only used in DTD. The format of the parameter entity is very similar to the general entity, but the "%" character is added in the middle.
Entity usage
In the object-oriented programming method, use entity needs to declaration first
User u = new user ();
U.AGE = 28
u.addr = "No. 238, Weihai Road, Qingdao, Shandong";
XML entity declaration method
The statement of the entity should be placed in the file type DOCTYPE. DOCTYPE is typically placed before the file header (ie XML declaration and DTD), before the XML element. In this way, the XML file becomes the form:
XML Version = "1.0"?>
Look at an instance (note that the entity is to add to the entity "to add in the entity, and it is necessary to add at the end;)
XML Version = "1.0" encoding = "GB2312"?>
]>
Contact>
Contact>
Contact>
Contact List>
This advantage is that you can only update the entity, so that all instances of this entity can be updated, very fast and convenient.