QT C++ Project (Creating Login with XML) - c++

I have question about my internship project. They want me to create a basic Login page(ID, Password). I create a XML file for Username and Password. The program should check the XML file for username and password*. If they are correct it will direct to a second window. I'm stuck on processing XML file for username and password. How can read those information in XML file.

As #JarMan said, I would recommend the QXmlStreamReader. You can fill it with a file (QIODevice), QString, QByteArray, etc...
Parsing a value could e.g. look like that
xml.attributes().value( attribute ).toString();
if attribute is a QString and xml is the QXmlStreamReader.
See the doc https://doc.qt.io/qt-5/qxmlstreamreader.html

There are several ways to do it. Marris mentioned one, but another one is to have this kind of code generated automatically. The way this works is that you first write an XML Schema that describes what your XML data looks like. An introduction to the XML Schema language can be found e. g. here.
Then you use an XML Schema compiler to translate the XML Schema to C++ classes. The schema compiler will also generate code to parse an XML file into objects, meaning you don't have to write any code to deal with XML by hand. It's a purely declarative approach: declare what the data looks like, and let the computer figure out the details.

Related

ColdFusion CF2021 xmlParse(file) returning wddx encoded object

UPDATE: After doing some more poking around, it looks as though the problem has to do with where CF is looking for the DTD file referenced in the XML.
We have the DTDs, but it looks as though CF isn't finding them, so it isn't sure how to parse the XML according to the DTD. I determined this by having it parse XML without any DTD, and it worked as expected and as I wanted - returning a parsed xmlDoc, not a string.
Is there some way of setting the default directory for where CF should look for the DTD specified in the XML?
We're running CF2021, and xmlParse(file), which should return a parsed XML object is instead returning the file contents as a string, inside a wddx encoded object. We have just migrated from a CF2018 server running on a remote hosting service to CF2021 running on an AWS box.
In order to return the XML object we need, I need to run xmlParse on the file, then wddx2cfml on the object, then xmlParse again on the string.
Is there a reason why xmlParse, which should return a parsed XML object, is instead behaving this way?
We pass the system file location to the method. Call it docPath, and it'd look something like g:\appName\xmlFiles\20230125.xml
Then we have, in cfscript:
doc = xmlParse(docPath);
When I dump that to a file, I get what I described above. When I change it to the following, I get what want:
docFile = xmlParse(docPath); cfwddx(action="wddx2cfml", input="#docFile#", output="xmlString"); xmlDoc = xmlParse(xmlString);
But I don't understand why this is necessary, and I'm concerned about having to change it everywhere in the code that we use xmlParse. For the record, this also occurs in tagged CF as well as cfscript, so it's not that.
Putting the dtd files in CF's WEB-INF folder solved the problem. CF was able to match the DTD with the DOCTYPE and properly parse the XML.

Is there any way to detect PDF/email in NetSuite Advanced PDFs?

Is there any way to detect if an advanced PDF is being used as a PDF or an email in NetSuite?
I would like to format accordingly.
Something like:
<#if current_format=="email">Show some html stuff.<#else>PDF version</#if>
There is no 'state' information available in to the template generator that I can think of. All it knows is the record context you(or NetSuite) gave it.
The output of the advanced template is XML regardless of its final destination. It's converted to PDF or HTMl output after having been generated. (See: nlapiCreateTemplateRenderer() and nlapiXMLToPDF() documentation in NetSuite for more info.)
If you need to format the content differently, the simplest method is probably to use 2 separate forms.

Architecture for a c++ XML-parser with a HTML-reportgenerator

I want a program that parses a XML-file, build a structure with the tags I need and finally print a HTML-report using HTML-templates with keywords that get replaced by the data from the XML files.
Since I'm not(yet) really into the OO programming I hoped to get some tips and advices how to structure a program like this.
I thought that two classes should be enough. A parser class and a data class.
the first one to go through the XML-file and report every tag I want to store to a data object which stores all the tags in a hierarchical order. After that I want to call a print function which prints everything as HTML-report.
I'm not sure how to report the tags to the data object
Could I store the tags in one object which stores a tree of structs or would it be better to store each tag in a separate object?
Any help would be greatly appreciated!
You don't mention Qt in your question, but as you added it as a tag: there is QtXML, which will give a way to parse and generate XML documents, and will also work for HTML output. XML is typically handled either via DOM or SAX. With DOM, the documents are parsed into a tree structure, and you will work on the tree as your central data element. With SAX, you use callback functions that are called for the different XML elements while parsing the XML input.
There is a lot about DOM and SAX on the internet, Wikipedia is a good starting point. There is also a lot of documentation on QtXML on-line.
Using DOM and/or SAX will give a nice architecture for solving the problem.
I solved my problem and want to share my architecture.
I made a Class Parser to parse the Elements and report the tags to an HTMLHandler class which has Subclasses like Header, Content and Sub-content. which store the Data and all have write()- methodes to print themselves out.
works fine for me and is quit simple :)

read file from url path and display in chart format

i working on one project. i want to read file which path from url,this file containing xml data i have to show this data in chart format.
Basically, your steps may be these:
Validate the URL data (StructKeyExists + FileExists + isFile).
Read and parse XML file, you can do this with XmlParse.
Convert XML object into the query (see query functions).
Render the data using great charting tags.
If you want more detailed help -- please expand your question, to make it more specific.

How do I view the contents of an IXMLDOMElementPtr when building an XML file?

I'm using IXMLDOM in MSXML 6 to build an XML file in a C++ MFC application. Is there a way to see the contents of the xml document while it is in memory?
For example, an XPATH query is failing about halfway through creating the file. How would I view the entire contents of the xml doc?
Thanks!
IXMLDOMElement derives from IXMLDOMNode, and IXMLDOMNode has an xml property that you can use to get the textual representation of the XML in memory.
IXMLDOMElementPtr spElement = ...;
_bstr_t xmlContents = spElement->xml();
If you're looking for a way to see the contents of the XML in the debugger without changing existing code to add this call, that may be possible, but I'm not exactly sure where to look.