Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

xml parsing - Are line breaks in XML attribute values allowed?

I realise that it's not elegant or desired, but is it allowed (in well-formed XML) for an attribute value in an XML element to span multiple lines?

e.g.

<some-xml-element value="this value goes over....
multiple lines!" />

Yeah I realise there's better ways of writing that. I would personally write it like:

<some-xml-element>
<value>this value goes over...
multiple lines!</value>
</some-xml-element>

or:

<some-xml-element value="this value goes over....&#13;&#10;" />

But we have our own XML parser and I'd like to know whether the first example is allowed in well-formed XML.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

http://www.w3.org/TR/REC-xml/#NT-AttValue

Seems to say everything except <, &, and your delimiter (' or ") are OK. So newline should be, too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...