Question : Using OPENXML in a Stored Procedure for an Infopath form submitted via Web Service

I posted a question previously that has led to another question needing clarification/guidance (see http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/Q_24969403.html). The part that I need help with is all of the examples I have found for using OPENXML contain the XML document in the code (in the code snippet following the 'EXEC sp_xml_preparedocument...' line). How can I reference an Infopath document being submitted via a web service rather than encoding the XML file in the stored procedure? FYI - the code snippet isn't the one I am using specifically, it is borrowed from another example so it may not be 100% correct.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
declare @XmlHandle int 
 
EXEC sp_xml_preparedocument @XmlHandle output, 
'
      
            
                  Smith 
                  John 
                  
1234 Main Street
Smith Mary [email protected]
' SELECT PlayerID, Lastname, Firstname, Address, ContactID, CLastName, CFirstName,email FROM OPENXML (@XmlHandle, '/Register/Player',1) With ( PlayerID int './Player/@PlayerID', Lastname varchar(50) 'Player/LastName', Firstname varchar(50) 'Player/FirstName', [Address] varchar(50) 'Player/Address', ContactID int './Contact/@ContactID', CLastname varchar(50) './Contact/CLastName', CFirstname varchar(50) './Contact/CFirstName', email varchar(50) './Contact/Email') exec sp_xml_removedocument @XmlHandle

Answer : Using OPENXML in a Stored Procedure for an Infopath form submitted via Web Service

I got an idea, change your incoming varable to a varchar(max).  Lets do a replace on the string coming in to strip the my:.  Look below, you should be able to cut and paste, see if that fixes that issue.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
DECLARE @idoc int
 
set @myFields = replace(@myFields, 'my:', '')
print @myFields
EXEC sp_xml_preparedocument @idoc OUTPUT, @myFields
 
Declare @ID as int
Declare @First varchar(10)
Declare @Last varchar(10)
 
Declare XMLCursor cursor for SELECT First , Last, ID FROM OPENXML( @idoc, 'myFields/Group1/Group2',1)
WITH ( ID Int 'ID',
First varchar(10) 'First',
Last varchar(10) 'Last'
) 
 
Open XMLCursor 
fetch next from XMLCursor
into @First, @Last, @ID
WHILE @@FETCH_STATUS = 0
Begin
insert into exp1 (First, Last, ID) values (@First, @Last, @ID)
fetch next from XMLCursor
into @First, @Last, @ID
end
close XMLCursor
Deallocate XMLCursor
 
EXEC sp_xml_removedocument @idoc
Random Solutions  
 
programming4us programming4us