Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

XML read fails on unknown xmlns field

See original GitHub issue

I am trying to read a standard Visual Studio NET Framework project file using ChoXmlReader (v1.1.28) as shown below. I’m running .28 because I have many project files that use ChoXmlReader and I don’t want to update them all unless I have to. The first two lines of the project file are:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="">

My code that reads the file looks like this:

  // parse the file and return the result
    try {
      var tmp = new ChoXmlReader<Project>(path).WithXPath("//").ToList();

The problem is that the read “fails” (does not load the project file elements) because of the broken xmlns https pathname. Putting the pathname into my browser shows the following error message:

The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

If I remove the xmlns attribute from the file, the ChoXmlReader code above properly reads the XML file. Is there any way that the ChoXmlReader could ignore broken xmlns pathnames? I don’t think VStudio is going to stop generating the xmlns for NET Framework project files any time soon.

I do not get an exception raised by ChoXmlReader, either. It properly reads and returns the “ToolsVersion” attribute on the Project line of the example above. So ChoXmlReader says there is no error (no exception) with the file, but it returns a class that is essentially empty and unusable. If it was my code, I would try to fail gracefully and ignore broken xmlns paths. I guess the file itself has a valid syntax, but the URL is broken. I vote for failing gracefully and ignoring the broken URL so that the reader could try to read the rest of the file. Thank you for the wonderful library!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

kevinj2016commented, Jan 30, 2022

Thank you so much for your help! It would have been impossible for me to figure that out on my own without doc. I think VStudio requires that xmlns line, so it might not be possible to remove it from all my project files. And it would probably get added back in on the rewrite of the csproj file the next time I changed a project property. Thank you!

Cinchoocommented, Feb 11, 2022

rolled out new beta version ChoETL.Core v1.2.1.43-beta2, handle the default namespace implicitly.

Sample fiddle:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reading XML fails when the parent node has XMLNS
I have a application where i read the xml information. It is working fine, but when my parent node has an XMLNS added...
Read more >
encoding/xml: option to treat unknown fields as an error ...
Yes, and the question is whether, if the xml:",chardata" fields are missing and the cdata would otherwise be thrown on the floor, there...
Read more >
XML Parser Error Codes
XML Parser Error Codes ; 1, The parser found an invalid character while scanning white space outside element content. ; 2, The parser...
Read more >
How to debug XMLSerializer.Deserialize error : 'There is ...
When I run the process, it fails with the messages 'There is an error in XML document (6, 3135)' and' Input string was...
Read more >
Knowledge 000110246 - Search - Informatica
This issue could occur when validating the XML source option in the session to set to 'Always validate' and the schema location is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found