How to read an XML file using Testcomplete? - testcomplete

I have an XML file of the following format:
<a>Test</a>
<Book>
<Title>ABC</Title>
<Price>123</Price>
<Author>Pete</Author>
</Book>
Is there anyway to read the contents using TC9 (jscript)? The xml file that i am using doesnot have a namespace.It is saved as .XML file but cannot be opened using web browser.It is basically used by us to store Logs of our app hence can be viewed via Notepad or Notepad++ .
Thanks !

You can find detailed information on how to work with XML files from a TestComplete script in the Working With XML Files From Scripts help topic.
The only concern I see is that the XML file you showed us does not have a root node. It must have a root node in order to make standard XML parsers work with it.

Related

The document \"<?xml version='1.0'?>\\n\" does not have a valid root

I am new to parsing the xml in the ruby and I am stuck with an issue. I'll try my best to explain.
I get the below response from an api
"PK\x03\x04\x14\x00\b\b\b\x00,\x18ET\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1D\x00\x00\x00"
I believe it is .tds format.
I am trying to parse it into a valid xml so this is what I tried.
xml = Nokogiri::XML(response)
which gives me #<Nokogiri::XML::Document:0xf744 name="document">
Then I tried to do Hash.from_xml(xml.to_xml)
But this throws error The document \"<?xml version='1.0'?>\\n\" does not have a valid root
Any idea what am I missing here?
This string starts with "PK", which are initials of Phil Katz, author of the ZIP format. Which means it's a ZIP file. There are certain formats that are ZIP files, but actually follow some further structure conventions, like Java JAR files, but also all OpenDocument formats like .ods, .odt and all MS Office Open XML formats.
Since you are probably expecting an .ods file... While you could unzip it and then use Nokogiri to parse the XML, there's a better way to proceed.
There's an interesting Gem called Roo, that supports all most common spreadsheet formats and produces a nice Ruby API to deal with them: https://github.com/roo-rb/roo
I would recommend you to save the string to a temporary file and then open it with Roo.

How to Attach PDF or Doc file in UI Path tool(Robotic Automation Process)

I am trying to send mail from UI path tool with attachment of PDF or DOC file.
Just provide an absolute path to a file. You can make use of variables, too - as the following example shows:

Ajax request to xml file outside of TideSDK application

I have a TideSDK application that will be in the same folder as another folder with an xml file and some images and videos in it.
[my application]
-> application.app
-> [data]
-> data.xml
-> image.jpg
Now I need to get the data in the xml file and also urls/filepath to the images/videos
Is this possible?
The application is working online without TideSDK by getting the data with ajax, so I'm trying to do it the same way here, but just changing the filepath to the xml.
I have tried to do this by hardcoding it, and using Ti.Filesystem.getFile(), but the result is always the same: pathToTheApplication/application.app/Contents/Resources/pathToTheApplication/data/data.xml.
So as you can see the second part of the url is correct, but it always starts from the Resources folder.
Is there any way to solve this?
You should be able to use getFile(). Are you making sure you are passing an absolute path to the file as opposed to a relative path?

Is Isolated Storage Always Necessary?

I see alot of examples on how to write data from an app to a file then put it in isolated storage. I do not want to write any data to my xml file, I just simply want to save it into isolated storage then query it later.
A few simple questions
Someone have code on how to put an existing xml file into isolated storage. Also since I am not writing to this file, do I need isolated storage still? Can I just add the xml to my project and use Linq to xml to open it query it and close it on a button click?
I wanna query the xml through my application in the background. I see alot of examples on serializing, do I need to do this? Can I just open the xml file and use linq to xml to query the data?
Can I just do this, set bbxml.xml to Content and forget about isolated storage and just do this?
using (XmlReader reader = XmlReader.Create("bbxml.xml"))
{
XDocument xml = XDocument.Load(reader);
//query xml....
}
Include the XML file in your project files in Visual Studio, then in the Properties window make sure Build Action is set to Content and Copy to Output Directory is set to Copy always or Copy if newer. This will include the file in the output XAP file.
To access this file in code use:
XDocument doc = XDocument.Load( "path/to/my/file.xml" );
Of course, it doesn't have to be XDocument, you can use any XML reader class similarly.

converting schema in XML to XSD for visual studio

Note, I am not trying to generate the schema for an XML file from the file. There is plenty about that on the web. Kind of a waste--how can a file fail validation if the validator was generated from the file it's validating?
Anyway, I want to test an SSIS component that requires a configuration file in XML (not XSD) to tell it how to parse another input file (this input is also not XML).
The provider of this component says we have to create our own config xml files. I would like to use Intellisense to help do that. There is a schema for these config files, but it is in XML.
Is there a way to create a schema from an XML file that represents the content of that file, not the structure?
Example is in second paragraph. Anyway, it turns out there is a way, and it's embarassingly simple.
Just rename the file from whatever.xml to whatever.xsd

Resources