XML learning notes (4)

xiaoxiao2021-03-06  74

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:

specific data content

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;)

]>

Zhang 3

A Company

& A Address;

Li 4 / Name>

B Company

& B Address;

Wang 5

B Company

& B Address;

This advantage is that you can only update the entity, so that all instances of this entity can be updated, very fast and convenient.

转载请注明原文地址:https://www.9cbs.com/read-121628.html

New Post(0)