Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Contributor
Posts: 66
Registered: ‎05-03-2016

Reading external XML File in Smart Client

Hi,

 

I have a Formfile button to import an xml file onto the Smart Client server.

I need to be able to read a field in this xml file but the AJAX xttp request script won't work. Below is my attempt.

 

 

var xhttp = new XMLHttpRequest();
			xhttp.onreadystatechange = function() {
				if (xhttp.readyState == 4 && xhttp.status == 200) {
				myFunction(xhttp);
				}
			};

			xhttp.open("GET",  IG._form.getItemById('Selected_File').value(), true);
			xhttp.send();

			function myFunction(xml) {
				var xmlDoc = xml.responseXML;
				var x = xmlDoc.getElementsByTagName('Hours')[0];
				var txt = x.getAttribute("Hours");
				IG._form.getItemById('Hours').value(x); 
			};

 

 

Is there a way to read from an external xml file within a Smart Client work. I'd like to populate a field on the form with this.

 

Regards,

 

Josh

Super Contributor
Posts: 301
Registered: ‎02-10-2016

Re: Reading external XML File in Smart Client

Hi JoshG,

 

Have you tried to create a your own MVC controller to process, in the workflow you can use Javascript AJAX based function to call your controller.

 

Kind regards

Contributor
Posts: 66
Registered: ‎05-03-2016

Re: Reading external XML File in Smart Client

Hi Bob,

 

I can give this a go. The only other thing is that this will be a different file each time.

The user imports the xml file to a certain location, and then they would import the Hours value into the form.

The next time they will import another xml file and do the same. The original will still live there.

 

I have built SQL triggers to read XML which almost works. If I can't get this to work I will look at the MVC route.

 

Thanks,

 

Josh

Super Contributor
Posts: 301
Registered: ‎02-10-2016

Re: Reading external XML File in Smart Client

Hi JoshG,

 

How about having a java plugin watches over that folder, so when you import a xml, it will rename the file (or marked it as read) so the newer won't interfere or overwrite it, you can also read the file in java and send the info straight to the server?

 

Kind regards, 

Contributor
Posts: 66
Registered: ‎05-03-2016

Re: Reading external XML File in Smart Client

I haven't any experience with Java, only Javascript and SQL, so my skills in Java are nil unfortunately.

I would like to get involved as we do use plugins that occasionally have issues. I will see how I go in the meantime and look at these as options.

 

Thanks,

 

Josh

Polls
Please register to vote
Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.