SUP/SUB tag in XML - html

Can i use Superscript and Subscript tags in XML file?
I tried copy pasting,using <SUP> tags but it is giving error .I have also searched a lot,but could not get proper solution.
Could anyone please suggest me solution?

There is nothing in the XML standard that precludes SUP or SUB elements.
However, they don't have any specific meaning in XML either.
If you expect them to show up as super and sub scripts, this will not happen.

You can use any tags you like in XML, that's the whole point of it.
Please never use the phrase "I tried it and it gave me an error" without telling us what the error was. We like to be helpful but we can't explain an error for you without seeing the error message. It's like telling your doctor you don't feel well without telling him the symptoms.

This XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>name</key>
<string>title</string>
<key>subchapters</key>
<string>name</string>
</dict>
</array>
</plist>
has reference to DTD in which element sub is not defined. This DTD is located http://www.apple.com/DTDs/PropertyList-1.0.dtd
I think you can omit DTD validation in your XML parser.

You can wrap your text in a CDATA tag, like so:
<![CDATA[ <string>haii</string> ]]>
The XML parser will not try to parse the content inside, but interpret it as a literal, which will solve your problem.

Related

More explanation about "XML doesn't support arrays" while there is the <array> tag

Many websites compare XML and JSON and mention that JSON supports arrays while XML doesn't support arrays.
While I can see that we have the tag in XML for example
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array
name="integer_array_name">
<item>resource</item>
</array>
</resources>
so any explanation about what it means by "XML doesn't support arrays"?
First of all XML is very flexibel language and it gave us an feature of declaring user define tags.
So it doesn't matter what tag name you gave,XML will declare it.
And in JSON arrays are almost the same as javascript .

Parsing an XML file with multiple <?xml> tags using Node.js/Express/xml2js

my problem is as follows:
I'm downloading an xml file using express.js and then parsing that file. Right now it looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE item [ ]>
<item lang="EN" >
<country>US</country>
<doc-number>123123123</doc-number>
<kind>A1</kind>
<date>20191017</date>
</item>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE item [ ]>
<item lang="EN" >
<country>US</country>
<doc-number>0938409384</doc-number>
<kind>A2</kind>
<date>20191018</date>
</item>
I'm using the xml2js library and I'm having trouble getting the entire document. My code looks something like this
parseString(xml, function (err, result) {
console.log(obj);
})
The XML only outputs only the first piece of xml. How can I parse this so I can get an array of <item>s?
My first idea is to loop through the doc as a string and split it based on <?xml version="1.0" encoding="UTF-8"?> and parse the data that way.
Thanks!
I do not think you can have more than one xml declarations for a single xml document. Additionally, a root element must always be present.
Therefore, the xml document you have provided is 2 separate xml documents, in principle. Most parsers or APIs would probably reject it, as not well formed.
Do you have any control over how the document is generated? If yes, you should ensure that a single xml declaration and a single root element will be present. Something similar to:
<?xml version=“1.0” encoding=“utf-8”>
<items>
<item>…</item>
<item>…</item>
</items>
If you do not have any control on the generation, you should probably split it and parse the documents separately, or concatenate them and generate a document similar to the one above.

Is it okay to have a <!-- comment --> as first line in SVG?

Can you have an XML comment as the first line in an SVG file? For example:
<!-- Timestamp 1434061994 -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg...
Is this against SVG spec? Or would it ever fail validation or would this cause any sort of problems I'm not seeing when implementing this in a website?
Yes, it is ok to have a comment be the first line in an SVG file, but only if there is no XML declaration (<?xml version="1.0" encoding="UTF-8"?>).
Nothing can appear before the XML declaration in an XML file. At most one XML declaration can appear in a file, and if an XML declaration is used, then it must be at the very top of the file. Anything before an XML declaration, including a comment, prevents the XML from being well-formed and should result in an error such as the following diagnostic by Xerces-J:
The processing instruction target matching "[xX][mM][lL]" is not
allowed.
If a comment appears before the XML declaration, then the XML is not well-formed, and if the XML is not well-formed, the SVG is not conforming.
Final note: An XML declaration is optional. Unless you want to specify a version other than 1.0 or an encoding other than UTF-8, you don't have to have an XML declaration in an XML (or SVG) file.

Flex how to specify the application encoding?

<?xml version="1.0" encoding="utf-8"?>
<s:Application
is that xml attribute encoding="utf-8" making the whole application in utf-8?, also the input forms and others? or where do I specify it?
The encoding you are referring to is the xml document encoding.
This tells the editor/compiler what the character definitions are.
Go ahead and change it to utf-16
What you want it the restrict property on the textinput

Sublime Text 2/3 class navigation to include class name in methods/fields

I'm using Sublime Text 3 on a large codebase, the entire LLVM + Clang.
One thing I'm seriously missing is the ability to goto a function belonging to a specific class.
To explain, let's say I'm in a file with 10+ classes, all having a method called getSourceRange().
The current goto symbol functionality only indexes the method names, so when I search for this method, I get a bunch of identical results that I have to go through manually until I find the right one. Using the project-wide Goto Symbol is worse as there are even more clashes.
What I'd like is for the indexed symbol name to always include the class name, e.g. VarDecl::getSourceRange instead of just getSourceRange. I can enable this for implementations outside-of-class by removing C++/Symbol Index.tmPreferences which essentially was stripping the CLASS:: from the indexed name. However I don't yet know how to inject the class name into definitions that are inside a class' scope.
The information is all there in the TextMate scopes, so I could technically add a rule for the following scope:
source.c++ meta.class-struct-block.c++ entity.name.function.c
But I don't know how to access the class' name as a string (stored in meta.class-struct-block.c++ » entity.name.type.c++ as saved in C++.tmLanguage), let alone format the function's indexed symbol name to include it.
Anyone know how to do this, if possible? TextMate's page explaining these mechanics doesn't mention this being possible, for what it's worth.
My attempt, stuck at how to insert a syntax name into the symbol(Index)?Transformation:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>source.c++ meta.class-struct-block.c++ entity.name.function.c</string>
<key>settings</key>
<dict>
<key>symbolIndexTransformation</key>
<string>/^/${entity.name.type.c++}::/;</string>
<key>symbolTransformation</key>
<string>/^/${entity.name.type.c++}::/;</string> <!-- just adds it literally :( -->
</dict>
</dict>
</plist>