开发者

Valid link with GET parameters

开发者 https://www.devze.com 2023-02-08 12:09 出处:网络
How can i place valid link with get parameters into my page? When i run validator, it gives error: Line 37, Column 37: reference to entity \"p\" for which no system identifie开发者_StackOverflow中文

How can i place valid link with get parameters into my page?

When i run validator, it gives error:

Line 37, Column 37: reference to entity "p" for which no system identifie开发者_StackOverflow中文版r could be generated
<li><a href="index.php?c=tutorials&p=cat&cid=1" >LINK</a></li>


from here http://css-discuss.incutio.com/wiki/Code_Validation

The most common error by far looks something like this: reference to entity "BV_Engine" for which no system identifier could be generated. What that means is simply that you've got a URL with an & sign in it that you forgot to escape.

For example: <a href="script.cgi?id=4&BV_Engine=20">

The & sign in this URL should be &. In fact ALL & signs in an HTML document should be escaped in this way to avoid causing confusion to HTML parsers. For the above example, replacing it with

<a href="script.cgi?id=4&amp;BV_Engine=20">


Escape your ampersands:

<li><a href="index.php?c=tutorials&amp;p=cat&amp;cid=1" >LINK</a></li>


You have to use & instead of plain &. Its an html entity.

<li><a href="index.php?c=tutorials&amp;p=cat&amp;cid=1" >LINK</a></li>


Yes, as the others have posted above, you need to escape your amparsands as &amp; rather than &.

<li><a href="index.php?c=tutorials&amp;p=cat&amp;cid=1">LINK</a></li>

should work.


To be compatible with XHTML (and XML in general), the ampersand must be escaped. To do so requires the use of an SGML/XML entity.

There are three different entities that can be used to represent the ampersand:

  1. Named entity: &amp; (This is one of the five predefined entities defined in the XML specification.)

  2. Decimal numeric character reference: &#38;

  3. Hexadecimal numeric character reference: &#x26;

So, the value of your example href attribute could be represented in one of these three ways:

href="index.php?c=tutorials&amp;p=cat&amp;cid=1"
href="index.php?c=tutorials&#38;p=cat&#38;cid=1"
href="index.php?c=tutorials&#x26;p=cat&#x26;cid=1"

Of course, it would be valid to mix the above entities like this:

href="index.php?c=tutorials&amp;p=cat&#38;cid=1"
                           ^^^^^     ^^^^^

...but most would argue for taking a consistent approach throughout a document (and even an entire web site).

Of the three entities that can be used to represent the ampersand, I believe that &amp; is used most commonly in XHTML.

Final note: One of the above entities should also be used when authoring HTML, however browsers today do not require that the ampersand be escaped.

0

精彩评论

暂无评论...
验证码 换一张
取 消