XHTML中的所有有效自闭元素(例如<br/>)是什么(由主要浏览器实现)?
我知道XHTML在技术上允许任何元素自我关闭,但我正在寻找所有主要浏览器支持的那些元素的列表.有关由自关闭元素(如<div />)引起的某些问题的示例,请参见http://dusan.fora.si/blog/self-closing-tags.
我们与一位客户存在某种问题,该客户认为我们发送的 XML 文件中的两个版本的空标记之间存在语义差异(纯 XML 没有 HTML ..)。
他们期望:
<our-xml>
<some-tag></some-tag>
</our-xml>
Run Code Online (Sandbox Code Playgroud)
我们发送:
<our-xml>
<some-tag />
</our-xml>
Run Code Online (Sandbox Code Playgroud)
我们认为这是完全相同的,但我们无法真正用事实证明这些论点。我们发现的唯一内容是在https://www.w3.org/TR/REC-xml/#sec-starttags中说的
空元素标签可用于任何没有内容的元素。
是否有任何讨论或更明确的论文可供我们依赖,或者我们错了?
对于某些Android XML属性,在插入格式化组件之前,不要使用">"结束开始标记.例如:
<EditText
android:id="@+id/etEmails">
</EditText>
Run Code Online (Sandbox Code Playgroud)
为什么在开始和结束标记中没有EditText组件的定义?另外,我注意到有些甚至不需要结束标记,而只是它们本身就是XML语句.例如:
<Button
android:text="Subtract 1"
android:id="@+id/buttSub"
/>
Run Code Online (Sandbox Code Playgroud)
为什么这个XML语句在实际提供与EditText字段相同的组件时不需要结束语句?
是否有一种故障保护方式可以知道哪些需要打开和关闭语句以获得正确的语法?
是否存在哪些列表/参考?
这些不同组件之间有什么区别?
我正在尝试通过以下循环创建一个包含人员及其孩子姓名的 XML 文件:
$xml_file = new XMLWriter();
$xml_file->startElement("People");
while ($list_of_people->current != NULL ){
$xml_file->writeElement("Person"); // create a new person
$xml_file->startElement('Person');
$xml_file->writeAttribute('name', $list_of_people->current->name); // add their name as an attribute
if ($list_of_people->current->children != NULL){
while ($list_of_people->current->child_current != NULL){ // if they have children create them as well
$xml_file->writeElement("Person");
$list_of_people->startElement('Person');
$xml_file->writeAttribute('name', $list_of_people->current->child_current->child_name);
$xml_file->endElement();
$list_of_people->current->child_current = $list_of_people->current->child_current->next;
}
}
$xml_file->endElement();
$list_of_people->current = $list_of_people->current->next;
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,在输出文件中,我应该有多个名为“Person”的元素,具体取决于列表中有多少人以及其中有多少人有孩子。
我希望最终的 XML 文档看起来像这样:
<People>
<Person name="Anna"></Person>
<Person name="Joe">
<Person name="Willy"></Person> // Joe has a child named Willy
</Person> …
Run Code Online (Sandbox Code Playgroud)