Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Android Java: error when reading a HTML document
 
 
I read a Web page as HTML with Android Java to find various items. However, when reading an error message coming soon as the position is iterated builder.parse.

Document doc = builder.parse(inputSource);
 

 
The error message reads

attr value delimiter missing!
(position:START_TAG <meta http-equiv='null'>@4:18 in java.io.StringReader@fdcff3)

 
So far I've evaluated a Web response that from the router.

//</ check >
InputSource inputSource = new InputSource(new StringReader(sXML));
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder =
null;
try {
builder = builderFactory.newDocumentBuilder();
Document doc = builder.parse(inputSource);

//--< Sid + ChallengeCode >--
Element rootElement = doc.getDocumentElement();
NodeList items = rootElement.getElementsByTagName(
"tname");
..


 

 
 
 
 
Solution:
With the DocumentBuilderFactory class, you can read xml documents and evaluate.
However, working with HTML in DocumentBuilderFactory leads to problems.
You have to change to a pure HTML parser
 
Alternative:
Jsoup HTML parser:
 
 
Note, based on:
Under the basic page of DocumentBuilderFactory
 
javax.Xml.parsers Class DocumentBuilderFactory
java.lang.Object
javax.xml.parsers.DocumentBuilderFactory
Defines of a factory API that enables applications to obtain a parser that produces DOM object trees from XML documents.
 
 

Attr value delimiter missing!
(position: START_TAG < meta http-equiv =' null ' > @ 4:18 pm in java.io.StringReader@fdcff3)

 
 
Current method to read the HTML document

private void fp_Contacts_Response(String sXML)
{
//----------------< fp_Contacts_Response() >----------------
//< check >
//</ check >
InputSource inputSource = new InputSource(new StringReader(sXML));
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder =
null;
try {
builder = builderFactory.newDocumentBuilder();
Document doc = builder.parse(inputSource);

//--< Sid + ChallengeCode >--
Element rootElement = doc.getDocumentElement();
NodeList items = rootElement.getElementsByTagName(
"tname");

//< check >
if(items.getLength()<=0){return;}
//</ check >

String sContacts="";
for (int iItem=0;iItem<=items.getLength();iItem++)
{
Node node= (Node) items.item(iItem);
sContacts =sContacts +
"\n" + node.getTextContent();
}


txtResult_Contacts.setText(sContacts);


} catch (ParserConfigurationException e) {
e.printStackTrace();
}
catch (SAXException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
//----------------</ fp_Contacts_Response() >----------------
}
 

 
 
Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de