I have a part of xml file
<Text><?xml version="1.0" encoding="utf-16"?>
<ObjectFilter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<FilterConditions>
<FilterCondition>
<PropertyFilters>
<PropertyFilter>
<PropertyName>Message</PropertyName>
<FilterValue xsi:type="xsd:string">PPM exceeds tolerance</FilterValue>
<FilterType>strExpr</FilterType>
<Operator>eq</Operator>
<CaseSensitive>true</CaseSensitive>
<Recursive>false</Recursive>
</PropertyFilter>
</PropertyFilters>
<Enabled>true</Enabled>
<ObjectTypeName>Spo.DataModel.UnixLogMessage</ObjectTypeName>
<ObjectClassGR>
<Guid>00000000-0000-0000-0000-000000000000</Guid>
</ObjectClassGR>
Here what is node Recursive meant,,it actually like this <Recursive>false</Recursive>
but how come it like < ;Recursive>false< ;/Recursive >
Can any one help me about this
How are you getting this XML file? From a webpage?
It seems that the way you are getting the text file is translating it as an HTML document and thus turning your '<' into < and your '>' into >
You need to ensure that the page is not interpreted as HTML. You could just copy-paste everything into Notepad first for a simple solution.
Related
This error,
The processing instruction target matching "[xX][mM][lL]" is not allowed
occurs whenever I run an XSLT page that begins as follows:
<?xml version="1.0" encoding="windows-1256"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="../header.xsl"/>
<xsl:template match="/">
<xsl:call-template name="pstyle"/>
<xsl:call-template name="Validation"/>
<xsl:variable name="strLang">
<xsl:value-of select="//lang"/>
</xsl:variable>
<!-- ////////////// Page Title ///////////// -->
<title>
<xsl:value-of select="//ListStudentFinishedExam.Title"/>
</title>
Note: I removed any leading spaces before the first line, but the error still occurs!
Xerces-based tools will emit the following error
The processing instruction target matching "[xX][mM][lL]" is not allowed.
when an XML declaration is encountered anywhere other than at the top of an XML file.
This is a valid diagnostic message; other XML parsers should issue a similar error message in this situation.
To correct the problem, check the following possibilities:
Some blank space or other visible content exists before the <?xml ?>
declaration.
Resolution: remove blank space or any other
visible content before the XML declaration.
Some invisible content exists before the <?xml ?>
declaration. Most commonly this is a Byte Order Mark
(BOM).
Resolution:
Remove the BOM using techniques such as those suggested by the W3C
page on the BOM in HTML.
A stray <?xml ?> declaration exists within the XML content.
This can happen when XML files are combined programmatically or
via cut-and-paste. There can only be one <?xml ?> declaration
in an XML file, and it can only be at the top.
Resolution: Search for
<?xml in a case-insensitive manner, and remove all but the top XML
declaration from the file.
Debug your XML file. Either there is space or added extra or fewer tags.
For better understanding build the project through the command line. Windows: gradlew build
In my case, AndroidManifest.xml has a blank space at the very first line
<Empty Row> // This Creates the issue
<?xml version="1.0" encoding="utf-8"?>
There was auto generated Copyright message in XML and a blank line before <resources> tag, once I removed it my build was successful.
just remove this line: <?xml version="1.0" encoding="utf-8"?> because this kind of error only come because of this line or you might also check the format of your line according the mentioned line in this answer.
I had a similar issue with 50,000 rdf/xml files in 5,000 directories (the Project Gutenberg catalog file). I solved it with riot (in the jena distribution)
the directory is cache/epub/NN/nn.rdf (where NN is a number)
in the directory above the directory where all the files are, i.e. in cache
riot epub/*/*.rdf --output=turtle > allTurtle.ttl
This produces possibly many warnings but the result is in a format which can be loaded into jena (using the fuseki web interface).
surprisingly simple (at least in this case).
Another reason of the above error is corrupted jar file. I got the same error but for Junit when running unit tests. Removing jar and downloading it again fixed the issue.
in my case was a wrong path in a config file: file was not found (path was wrong) and it came out with this exception:
Error configuring from input stream. Initial cause was The processing
instruction target matching "[xX][mM][lL]" is not allowed.
For PHP, put this line of code before you start printing your XML:
while(ob_get_level()) ob_end_clean();
It's worth checking your server's folders to see if there's a stray pom.xml hanging around.
I found that I had the problem everyone else described with a malformed pom.xml, but in a folder that I didn't expect to be on the server. An old build was sticking around unwelcome D:
For my case, the tab is the trouble maker. Replace the tab with blank should resolve the issue
I am currently writing an XML writer/reader. I have it writing to the xml file, now I am attempting to read from it. However, when I do so the following error is thrown and I am not sure why:
'>' is an unexpected token. The expected token is '='. Line 6, position 16. XML reader c#
Please could someone shed some light on this for me?
The XML file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assignments>
<assignment>
<ModuleTitle>Internet Programming</ModuleTitle>
<AssignmentTitle>Assignment 01</AssignmentTitle>
<Date Given>11/02/2015</Date Given>
<Date Due>20/02/2015</Date Due>
</assignment>
</assignments>
UPDATE:
The problem was the fact that in some of my tag names I had spaces, which was causing the error.
You have invalid spaces, the following will work:
XElement config = XElement.Parse (
#"<?xml version='1.0' encoding='utf-8' standalone='yes'?>
<assignments>
<assignment>
<ModuleTitle>Internet Programming</ModuleTitle>
<AssignmentTitle>Assignment 01</AssignmentTitle>
<DateGiven>11/02/2015</DateGiven>
<DateDue>20/02/2015</DateDue>
</assignment>
</assignments>");
Please note DateGiven and DateDuewithout spaces.
The spaces are the reason for the error as shown below:
<Date Given> is not a valid XML syntax. Given is supposed to be an attribute with a value, so it should look something like this: <Date Given="true">
Edit to be useful in the future: as #James mentioned, it is just a space in the tag name, which is also invalid in XML.
Here is how to remove all namespace from xml. But it is not working for me. Because sometimes I am getting broken xml feed. eg:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress.com" -->
<rss version="2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<channel>
<title>sabri ?lker - WordPress.com Search</title>
<link>http://tr.search.wordpress.com/?q=sabri+%C3%BClker&page=2&t=comment&s=date</link>
<description>sabri ?lker - WordPress.com Search</description>
<pubDate>Fri, 04 Jan 2013 08:58:41 +0000</pubDate>
<language>tr</language>
<image><url>http://s.wordpress.com/i/buttonw-com.png</url><width>224</width><height>58</height><title>WordPress.com</title><link>http://wordpress.com/</link></image>
<generator>http://search.wordpress.com/</generator>
<atom:link rel="self" type="application/rss+xml" href="http://tr.search.wordpress.com/?q=sabri+%C3%BClker&page=2&t=comment&s=date&f=feed" />
<atom:link rel="search" type="application/opensearchdescription+xml" href="http://en.search.wordpress.com/opensearch.xml" title="WordPress.com" />
<opensearch:totalResults>10</opensearch:totalResults><opensearch:startIndex>11</opensearch:startIndex><opensearch:itemsPerPage>10</opensearch:itemsPerPage><opensearch:Query role="request" searchTerms="sabri ?lker startPage=\"2" /></channel>
</rss>
my exceptiom is "Name cannot begin with the '2' character, hexadecimal value 0x32. Line 17, position 227." to the result. So what should I do to solved this problem.
I'd say the reason is the ill-formed searchTerms attribute:
searchTerms="sabri ?lker startPage=\"2"
It's quoted the wrong way it should use " instead of \". You could simply replace all \" with "
string input = ..; // your xml
string processedInput = input.Replace("\\\"", """);
// then feed this into your xml parser.
This should solve your issue, but it's of course not a general way of sanitizing wrong xml input. You may want to have a look at http://tidyfornet.sourceforge.net/ it can sanitize HTML, XHTML and XML.
Idea - List of vertices(Key, X, Y, Priority to store).
<?xml version="1.0" encoding="utf-8"?>
<Vertices>
<Vertex Key="0" X="149" Y="209" Priority="7" />
<Vertex Key="1" X="278" Y="128" Priority="7" />
</Vertex>
Is this valid XML? It keeps saying me that root element is missing, when i try to open it... If so, can someone provide a valid c# XDocument code to open this file ?
It's not valid XML - your closing element has the wrong name - this would be valid:
<?xml version="1.0" encoding="utf-8"?>
<Vertices>
<Vertex Key="0" X="149" Y="209" Priority="7" />
<Vertex Key="1" X="278" Y="128" Priority="7" />
</Vertices>
Also make sure that if you are loading an XML file you use XDocument.Load and not XDocument.Parse.
You are opening <Vertices> but closing </Vertex>. Need to change that last closing tag to </Vertices>
Side note:
If you load an XML file into Visual Studio it will tell you if it is invalid XML and why. For this example it gave the errors:
Error 1 Tag was not closed. XMLFile1.xml Line 2 Column 5
Error 2 Expecting end tag </Vertices>. XMLFile1.xml Line 5 Column 6
If you do not own Visual Studio, you can download the Express version for free and get the same functionality.
I have a simple XML file, shown below, which when read-in via a basic XmlDocument.Load(filename.xml). If I load the file, and inspect it's innerXML, it all looks normal. However, when I inspect the value of DocumentElement, it's a mess!!! I kept the example small, so you can easily see there is no mal-formation:
<?xml version="1.0" encoding="UTF-8"?>
<fax:FaxService xmlns:fax="http://www.hp.com/schemas/imaging/con/service/fax/2009/02/11/" xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/">
<fax:ServiceDefaults>
<fax:ServiceSendDefaults>
<fax:InternetFaxSettings>
<dd:FaxFileFormat>MTIFFG4</dd:FaxFileFormat>
<dd:UseEmailAsFaxAcctAddr>false</dd:UseEmailAsFaxAcctAddr>
<dd:AutoCompleteToNANP>false</dd:AutoCompleteToNANP>
<dd:RetryInterval>0</dd:RetryInterval>
<dd:MaxRetryAttempts>0</dd:MaxRetryAttempts>
</fax:InternetFaxSettings>
</fax:ServiceSendDefaults>
</fax:ServiceDefaults>
</fax:FaxService>
Now, try this in C# with this simple code:
...
XmlDocument xDoc = new XmlDocument();
xDoc.Load("*XMLSAMPLE.XML*");
textBox1.Text = xDoc.InnerXml;
textBox2.Text = xDoc.DocumentElement.InnerXml;
...
It's completely mangled, with the 2nd namespace repeated with every dd tag, and not even included in the top-most tag.
What am I doing wrong? This is driving me nuts!
The content returned by xDoc.DocumentElement.InnerXml is semantically identical to your original ServiceDefaults tag - if the first fragment conforms to your XML schema, the InnerXml fragment will also conform to the definition of the inner element. Just because the framework has re-arranged the namespace declarations does not change the semantics of the document.
Compare the output of your the two XmlDocument properties:
xDoc.DocumentElement:
<?xml version="1.0" encoding="UTF-8"?>
<fax:FaxService xmlns:fax="http://www.hp.com/schemas/imaging/con/service/fax/2009/02/11/" xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/">
<fax:ServiceDefaults>
<fax:ServiceSendDefaults>
<fax:InternetFaxSettings>
<dd:FaxFileFormat>MTIFFG4</dd:FaxFileFormat>
<dd:UseEmailAsFaxAcctAddr>false</dd:UseEmailAsFaxAcctAddr>
<dd:AutoCompleteToNANP>false</dd:AutoCompleteToNANP>
<dd:RetryInterval>0</dd:RetryInterval>
<dd:MaxRetryAttempts>0</dd:MaxRetryAttempts>
</fax:InternetFaxSettings>
</fax:ServiceSendDefaults>
</fax:ServiceDefaults>
</fax:FaxService>
xDoc.DocumentElement.InnerXml:
<fax:ServiceDefaults xmlns:fax="http://www.hp.com/schemas/imaging/con/service/fax/2009/02/11/">
<fax:ServiceSendDefaults>
<fax:InternetFaxSettings>
<dd:FaxFileFormat xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/">MTIFFG4</dd:FaxFileFormat>
<dd:UseEmailAsFaxAcctAddr xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/">false</dd:UseEmailAsFaxAcctAddr>
<dd:AutoCompleteToNANP xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/">false</dd:AutoCompleteToNANP>
<dd:RetryInterval xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/">0</dd:RetryInterval>
<dd:MaxRetryAttempts xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/">0</dd:MaxRetryAttempts>
</fax:InternetFaxSettings>
</fax:ServiceSendDefaults>
</fax:ServiceDefaults>
A look at the following link in MSDN will help shed light on your situation:
http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.innerxml.aspx
Basically, xDoc.DocumentElement.InnerXml is looking at the <fax:ServiceDefaults> node, whereas xDoc.InnerXml is looking one level higher (FaxService node). This is crucial to understanding your problem - because all of your xmlns is on the FaxService node.
Make the following change to your XML document, and notice what happens (basically, copy over the xmlns info to the ServiceDefaults node:
<?xml version="1.0" encoding="UTF-8"?>
<fax:FaxService xmlns:fax="http://www.hp.com/schemas/imaging/con/service/fax/2009/02/11/" xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/">
<fax:ServiceDefaults xmlns:fax="http://www.hp.com/schemas/imaging/con/service/fax/2009/02/11/" xmlns:dd="http://www.hp.com/schemas/imaging/con/dictionaries/1.0/">
<fax:ServiceSendDefaults>
<fax:InternetFaxSettings>
<dd:FaxFileFormat>MTIFFG4</dd:FaxFileFormat>
<dd:UseEmailAsFaxAcctAddr>false</dd:UseEmailAsFaxAcctAddr>
<dd:AutoCompleteToNANP>false</dd:AutoCompleteToNANP>
<dd:RetryInterval>0</dd:RetryInterval>
<dd:MaxRetryAttempts>0</dd:MaxRetryAttempts>
</fax:InternetFaxSettings>
</fax:ServiceSendDefaults>
</fax:ServiceDefaults>
</fax:FaxService>
Suddenly your code will behave according to your expectations. So hopefully this helps you towards understanding the issue. What the permanent fix should be, that's up to you.
HTH!