DataConnection Data

S

Shem

Hi Folks,

I have amanged to extract the data from a dataconnection into an xml format
but I cannot seem to parse it.

Code:

Dim myDataAdapter
Dim dcEmployees
Dim iNodes

'Departments is the name of SHarepoint dataconnection
Set myDataAdapter = XDocument.DataAdapters("Departments")
myDataAdapter.Query
Set dcEmployees = XDocument.GetDOM("Departments")
'here i can get the dcEmployees.xml

'now get a list of nodes within xml
Set iNodes = dcEmployees.SelectNodes("//dsf:Departments")

At this point nothing happens, I cannot get a list of nodes, but if I run
this in VB (where I load the xml string from data connection) this works OK
when I do a selectnodes. I had an issue the other day with regards to the
namespace but this seems to have corrected itself, I think. But I think I
should still be able to parse this data

I have no idea why this is not working and would really love to find out how
I can get round this.

Thanks

Allan
 
S

Shem

Hi Greg,

Have you tried this? the reason I ask is that the namespaces are already
listed in the xml document: The extract is as follows:

<dfs:myFields
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"><dfs:dataFields><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="1" Department="Technology"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="2" Department="Learning & Development"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="3" Department="Human Resources"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="4" Department="FIS"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ID="5" Department="Finance"/></dfs:dataFields></dfs:myFields>

So do I still need to do the SetProperty thing?????? I will try it out, but
I was thinking that if the namespace info was already in the xml file then
that was all I needed.

Greg Collins said:
You need to see what namespaces are specified in Departments, and then add them to the DOM of that data source so that you can query the DOM.


If you are using script, the first line created by InfoPath demonstrates the technique which is somthing like:

XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:abc="http://foo.bar.com/abc"');


If you are using managed code, you need to do something like the following:

IXMLDOMDocument2 domFoo = (IXMLDOMDocument2)thisXDocument.GetDOM("Foo");
domFoo.setProperty("SelectionNamespaces", "xmlns:abc=\"http://foo.bar.com/abc\"");

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Folks,

I have amanged to extract the data from a dataconnection into an xml format
but I cannot seem to parse it.

Code:

Dim myDataAdapter
Dim dcEmployees
Dim iNodes

'Departments is the name of SHarepoint dataconnection
Set myDataAdapter = XDocument.DataAdapters("Departments")
myDataAdapter.Query
Set dcEmployees = XDocument.GetDOM("Departments")
'here i can get the dcEmployees.xml

'now get a list of nodes within xml
Set iNodes = dcEmployees.SelectNodes("//dsf:Departments")

At this point nothing happens, I cannot get a list of nodes, but if I run
this in VB (where I load the xml string from data connection) this works OK
when I do a selectnodes. I had an issue the other day with regards to the
namespace but this seems to have corrected itself, I think. But I think I
should still be able to parse this data

I have no idea why this is not working and would really love to find out how
I can get round this.

Thanks

Allan
 
S

Shem

HI Greg,

Thanks, I sent you an e-mail directly to show you exactly what I have done
and hope that you may be able to assist. There is obviously something I am
doing wrong but don't know what. Hope you received the e-mail if not I can
re-send the small 3 or 4 line script

Greg Collins said:
It is because the namespaces are listed in the xml document that you have to set the property on the xml DOM. Note -- the DOM must know about the namespaces contained in the document or you will not be able to make a selection. That is why you must set the property.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Greg,

Have you tried this? the reason I ask is that the namespaces are already
listed in the xml document: The extract is as follows:

<dfs:myFields
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"><dfs:dataFields><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="1" Department="Technology"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="2" Department="Learning & Development"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="3" Department="Human Resources"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="4" Department="FIS"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ID="5" Department="Finance"/></dfs:dataFields></dfs:myFields>

So do I still need to do the SetProperty thing?????? I will try it out, but
I was thinking that if the namespace info was already in the xml file then
that was all I needed.

Greg Collins said:
You need to see what namespaces are specified in Departments, and then add them to the DOM of that data source so that you can query the DOM.


If you are using script, the first line created by InfoPath demonstrates the technique which is somthing like:

XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:abc="http://foo.bar.com/abc"');


If you are using managed code, you need to do something like the following:

IXMLDOMDocument2 domFoo = (IXMLDOMDocument2)thisXDocument.GetDOM("Foo");
domFoo.setProperty("SelectionNamespaces", "xmlns:abc=\"http://foo.bar.com/abc\"");

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Folks,

I have amanged to extract the data from a dataconnection into an xml format
but I cannot seem to parse it.

Code:

Dim myDataAdapter
Dim dcEmployees
Dim iNodes

'Departments is the name of SHarepoint dataconnection
Set myDataAdapter = XDocument.DataAdapters("Departments")
myDataAdapter.Query
Set dcEmployees = XDocument.GetDOM("Departments")
'here i can get the dcEmployees.xml

'now get a list of nodes within xml
Set iNodes = dcEmployees.SelectNodes("//dsf:Departments")

At this point nothing happens, I cannot get a list of nodes, but if I run
this in VB (where I load the xml string from data connection) this works OK
when I do a selectnodes. I had an issue the other day with regards to the
namespace but this seems to have corrected itself, I think. But I think I
should still be able to parse this data

I have no idea why this is not working and would really love to find out how
I can get round this.

Thanks

Allan
 
S

Shem

Hi Greg,

I have tried this four ways 1) with dfs 2) with dsf 3) wth both and 4)
without both and every time I get the following error:

Referenece to undeclared namespace prefix dsf:

THe code in teh form I have is:

var dcEmployees;
var iNodes;

XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');

dcEmployees = XDocument.GetDOM("Employees");
XDocument.UI.Alert(dcEmployees.xml);
iNodes = dcEmployees.selectNodes("//dsf:Employees");
XDocument.UI.Alert(iNodes.Count);

And still getting nothing back for iNodes. DO you have access to sharepoint.
The reason I am asking is to see if you can get this to work on your
machine???

Regards,

Allan

Greg Collins said:
Hi, two things...

FIRST:
When you set the SelectionNamesapces property, you do it only once for all namespaces... like this:

XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');


SECOND:
Maybe someone else can say for sure, but I'm not positive whether you can have two namespace prefixes that have the same namespace definitions... right now you have both DSF and DFS with the same definition...

The other thing about this is that I wonder if the DSF one should even be there. The DFS prefix is just an acronym for "dataFromSolution".

My guess is that you should be using the following call (using the DFS namespace):

iNodes = dcEmployees.SelectNodes("//dfs:Departments");

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com




Hi Greg,

Thanks for all you assistance but I still cannot get my issue to work.

Basically, I have an InfoPath form connected to a receive data data connection called Departments on SharePoint

The script on the form is as follows:

function XDocument::OnLoad(eventObj)
{
Var dcDepartments;
Var iNodes;

//2 namespaces added as 2 are listed within xml
XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');
XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');
dcDepartments = XDocument.GetDOM("Departments");

XDocument.UI.Alert(dcEmployees.xml);
//the xml that comes back is as attached below

iNodes = dcEmployees.SelectNodes("//dsf:Departments");
}

Everything works up until I do the iNodes query. I have no idea why it is still not parsing. I hope you can help


HI Greg,

Thanks, I sent you an e-mail directly to show you exactly what I have done
and hope that you may be able to assist. There is obviously something I am
doing wrong but don't know what. Hope you received the e-mail if not I can
re-send the small 3 or 4 line script

Greg Collins said:
It is because the namespaces are listed in the xml document that you have to set the property on the xml DOM. Note -- the DOM must know about the namespaces contained in the document or you will not be able to make a selection. That is why you must set the property.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Greg,

Have you tried this? the reason I ask is that the namespaces are already
listed in the xml document: The extract is as follows:

<dfs:myFields
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"><dfs:dataFields><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="1" Department="Technology"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="2" Department="Learning & Development"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="3" Department="Human Resources"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="4" Department="FIS"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ID="5" Department="Finance"/></dfs:dataFields></dfs:myFields>

So do I still need to do the SetProperty thing?????? I will try it out, but
I was thinking that if the namespace info was already in the xml file then
that was all I needed.

Greg Collins said:
You need to see what namespaces are specified in Departments, and then add them to the DOM of that data source so that you can query the DOM.


If you are using script, the first line created by InfoPath demonstrates the technique which is somthing like:

XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:abc="http://foo.bar.com/abc"');


If you are using managed code, you need to do something like the following:

IXMLDOMDocument2 domFoo = (IXMLDOMDocument2)thisXDocument.GetDOM("Foo");
domFoo.setProperty("SelectionNamespaces", "xmlns:abc=\"http://foo.bar.com/abc\"");

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Folks,

I have amanged to extract the data from a dataconnection into an xml format
but I cannot seem to parse it.

Code:

Dim myDataAdapter
Dim dcEmployees
Dim iNodes

'Departments is the name of SHarepoint dataconnection
Set myDataAdapter = XDocument.DataAdapters("Departments")
myDataAdapter.Query
Set dcEmployees = XDocument.GetDOM("Departments")
'here i can get the dcEmployees.xml

'now get a list of nodes within xml
Set iNodes = dcEmployees.SelectNodes("//dsf:Departments")

At this point nothing happens, I cannot get a list of nodes, but if I run
this in VB (where I load the xml string from data connection) this works OK
when I do a selectnodes. I had an issue the other day with regards to the
namespace but this seems to have corrected itself, I think. But I think I
should still be able to parse this data

I have no idea why this is not working and would really love to find out how
I can get round this.

Thanks

Allan
 
S

Shem

Hi Greg,

SOLVED IT:

I set my object to GetDOM, then I use setProperty on new object not the
original XDocument.
So I have

dcEmployees = XDocument.GetDOM("Employees");
dcEmployees.setProperty("SelectionNamespaces",
'xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');

Greg Collins said:
Hi, two things...

FIRST:
When you set the SelectionNamesapces property, you do it only once for all namespaces... like this:

XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');


SECOND:
Maybe someone else can say for sure, but I'm not positive whether you can have two namespace prefixes that have the same namespace definitions... right now you have both DSF and DFS with the same definition...

The other thing about this is that I wonder if the DSF one should even be there. The DFS prefix is just an acronym for "dataFromSolution".

My guess is that you should be using the following call (using the DFS namespace):

iNodes = dcEmployees.SelectNodes("//dfs:Departments");

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com




Hi Greg,

Thanks for all you assistance but I still cannot get my issue to work.

Basically, I have an InfoPath form connected to a receive data data connection called Departments on SharePoint

The script on the form is as follows:

function XDocument::OnLoad(eventObj)
{
Var dcDepartments;
Var iNodes;

//2 namespaces added as 2 are listed within xml
XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');
XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');
dcDepartments = XDocument.GetDOM("Departments");

XDocument.UI.Alert(dcEmployees.xml);
//the xml that comes back is as attached below

iNodes = dcEmployees.SelectNodes("//dsf:Departments");
}

Everything works up until I do the iNodes query. I have no idea why it is still not parsing. I hope you can help


HI Greg,

Thanks, I sent you an e-mail directly to show you exactly what I have done
and hope that you may be able to assist. There is obviously something I am
doing wrong but don't know what. Hope you received the e-mail if not I can
re-send the small 3 or 4 line script

Greg Collins said:
It is because the namespaces are listed in the xml document that you have to set the property on the xml DOM. Note -- the DOM must know about the namespaces contained in the document or you will not be able to make a selection. That is why you must set the property.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Greg,

Have you tried this? the reason I ask is that the namespaces are already
listed in the xml document: The extract is as follows:

<dfs:myFields
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"><dfs:dataFields><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="1" Department="Technology"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="2" Department="Learning & Development"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="3" Department="Human Resources"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="4" Department="FIS"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ID="5" Department="Finance"/></dfs:dataFields></dfs:myFields>

So do I still need to do the SetProperty thing?????? I will try it out, but
I was thinking that if the namespace info was already in the xml file then
that was all I needed.

Greg Collins said:
You need to see what namespaces are specified in Departments, and then add them to the DOM of that data source so that you can query the DOM.


If you are using script, the first line created by InfoPath demonstrates the technique which is somthing like:

XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:abc="http://foo.bar.com/abc"');


If you are using managed code, you need to do something like the following:

IXMLDOMDocument2 domFoo = (IXMLDOMDocument2)thisXDocument.GetDOM("Foo");
domFoo.setProperty("SelectionNamespaces", "xmlns:abc=\"http://foo.bar.com/abc\"");

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Folks,

I have amanged to extract the data from a dataconnection into an xml format
but I cannot seem to parse it.

Code:

Dim myDataAdapter
Dim dcEmployees
Dim iNodes

'Departments is the name of SHarepoint dataconnection
Set myDataAdapter = XDocument.DataAdapters("Departments")
myDataAdapter.Query
Set dcEmployees = XDocument.GetDOM("Departments")
'here i can get the dcEmployees.xml

'now get a list of nodes within xml
Set iNodes = dcEmployees.SelectNodes("//dsf:Departments")

At this point nothing happens, I cannot get a list of nodes, but if I run
this in VB (where I load the xml string from data connection) this works OK
when I do a selectnodes. I had an issue the other day with regards to the
namespace but this seems to have corrected itself, I think. But I think I
should still be able to parse this data

I have no idea why this is not working and would really love to find out how
I can get round this.

Thanks

Allan
 
S

Shem

Hi Greg,

Instead of using a data connection I can ad a web reference in C#. How do I
access the service and run a method???

Greg Collins said:
I'm glad you got it! Yes, in your previous post you are messing up the selection namespaces for the main dom... making it so you won't be able to make any more selections from that.

Keep up the good work!

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Greg,

SOLVED IT:

I set my object to GetDOM, then I use setProperty on new object not the
original XDocument.
So I have

dcEmployees = XDocument.GetDOM("Employees");
dcEmployees.setProperty("SelectionNamespaces",
'xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');

Greg Collins said:
Hi, two things...

FIRST:
When you set the SelectionNamesapces property, you do it only once for all namespaces... like this:

XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');


SECOND:
Maybe someone else can say for sure, but I'm not positive whether you can have two namespace prefixes that have the same namespace definitions... right now you have both DSF and DFS with the same definition...

The other thing about this is that I wonder if the DSF one should even be there. The DFS prefix is just an acronym for "dataFromSolution".

My guess is that you should be using the following call (using the DFS namespace):

iNodes = dcEmployees.SelectNodes("//dfs:Departments");

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com




Hi Greg,

Thanks for all you assistance but I still cannot get my issue to work.

Basically, I have an InfoPath form connected to a receive data data connection called Departments on SharePoint

The script on the form is as follows:

function XDocument::OnLoad(eventObj)
{
Var dcDepartments;
Var iNodes;

//2 namespaces added as 2 are listed within xml
XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');
XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');
dcDepartments = XDocument.GetDOM("Departments");

XDocument.UI.Alert(dcEmployees.xml);
//the xml that comes back is as attached below

iNodes = dcEmployees.SelectNodes("//dsf:Departments");
}

Everything works up until I do the iNodes query. I have no idea why it is still not parsing. I hope you can help


HI Greg,

Thanks, I sent you an e-mail directly to show you exactly what I have done
and hope that you may be able to assist. There is obviously something I am
doing wrong but don't know what. Hope you received the e-mail if not I can
re-send the small 3 or 4 line script

Greg Collins said:
It is because the namespaces are listed in the xml document that you have to set the property on the xml DOM. Note -- the DOM must know about the namespaces contained in the document or you will not be able to make a selection. That is why you must set the property.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Greg,

Have you tried this? the reason I ask is that the namespaces are already
listed in the xml document: The extract is as follows:

<dfs:myFields
xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"><dfs:dataFields><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="1" Department="Technology"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="2" Department="Learning & Development"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="3" Department="Human Resources"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"
ID="4" Department="FIS"/><dsf:Departments
xmlns:dsf="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ID="5" Department="Finance"/></dfs:dataFields></dfs:myFields>

So do I still need to do the SetProperty thing?????? I will try it out, but
I was thinking that if the namespace info was already in the xml file then
that was all I needed.

:

You need to see what namespaces are specified in Departments, and then add them to the DOM of that data source so that you can query the DOM.


If you are using script, the first line created by InfoPath demonstrates the technique which is somthing like:

XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:abc="http://foo.bar.com/abc"');


If you are using managed code, you need to do something like the following:

IXMLDOMDocument2 domFoo = (IXMLDOMDocument2)thisXDocument.GetDOM("Foo");
domFoo.setProperty("SelectionNamespaces", "xmlns:abc=\"http://foo.bar.com/abc\"");

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



Hi Folks,

I have amanged to extract the data from a dataconnection into an xml format
but I cannot seem to parse it.

Code:

Dim myDataAdapter
Dim dcEmployees
Dim iNodes

'Departments is the name of SHarepoint dataconnection
Set myDataAdapter = XDocument.DataAdapters("Departments")
myDataAdapter.Query
Set dcEmployees = XDocument.GetDOM("Departments")
'here i can get the dcEmployees.xml

'now get a list of nodes within xml
Set iNodes = dcEmployees.SelectNodes("//dsf:Departments")

At this point nothing happens, I cannot get a list of nodes, but if I run
this in VB (where I load the xml string from data connection) this works OK
when I do a selectnodes. I had an issue the other day with regards to the
namespace but this seems to have corrected itself, I think. But I think I
should still be able to parse this data

I have no idea why this is not working and would really love to find out how
I can get round this.

Thanks

Allan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top