简体   繁体   中英

Java-XML parsing for data

I have an XML file with the following data:

<TextType name="ExtraBig_22p">
<font name="Optima" size="18" style="BOLD" env="osx" lang=""/>
<font name="Cyberbit" size="22" style="PLAIN" env="any" lang="Chinese"/>
<font name="Cyberbit" size="22" style="PLAIN" env="any" lang="Korean"/>
<font name="Calibri_bold" size="22" style="BOLD" env="default" lang=""/>
</TextType>
<TextType name="Big_18p">
<font name="Optima" size="16" style="BOLD" env="osx" lang=""/>
<font name="Cyberbit" size="18" style="PLAIN" env="any" lang="Chinese"/>
<font name="Cyberbit" size="18" style="PLAIN" env="any" lang="Korean"/>
<font name="Calibri_bold" size="18" style="BOLD" env="default" lang=""/>
</TextType>

When i parse this i get lineNumber: 8; columnNumber: 2; The markup in the document following the root element must be well-formed. Please help.

You xml is not a valid xml. To validate it add a root element to the top of the document.

<root>

xml content

</root>

Check here xml validator .

For xml to be valid :

  1. The XML document must have one root element.

  2. XML elements must be closed in the order they are opened.

  3. Any entities that are referenced in the document must also be well-formed.

您的文档没有根元素: http : //en.wikipedia.org/wiki/Root_element

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM