"BLL_Assessments" in this line should be "BLL_Assessment"
var result=from item in XDocument.Load ("Assessments.xml").Descendants
("BLL_Assessment")
On Fri, Jun 29, 2012 at 11:17 AM, proindigo <[email protected]> wrote:
> Well just sorted out the issue. Rechecked my code blocks and used the
> scopes{} properly and now the data is being inserted into the table just
> fine. Now I am facing another issue. I am generating an xml file by
> serializing the output received from a webservice and am trying to parse
> this document and insert the data into database. The format of the xml file
> is a bit complex for me [my knowledge of xml manipulation is not strong]. I
> am having trouble reading it.
>
> Here is my xml document -->
> <?xml version="1.0" encoding="utf-8" ?>
> - <ArrayOfBLL_Assessment
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> - <BLL_Assessment>
> <AssessmentID xmlns="http://tempuri.org/">5</AssessmentID>
> <ProjectName xmlns="http://tempuri.org/">ddd</ProjectName>
> <ClientID xmlns="http://tempuri.org/">1</ClientID>
> <ProjectID xmlns="http://tempuri.org/">5</ProjectID>
> <AssessmentStatusID xsi:nil="true" xmlns="http://tempuri.org/" />
> <ExpectedStartDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedStartDate>
> <ExpectedEndDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedEndDate>
> <FacilityID xmlns="http://tempuri.org/">0</FacilityID>
> </BLL_Assessment>
> - <BLL_Assessment>
> <AssessmentID xmlns="http://tempuri.org/">2</AssessmentID>
> <ProjectName xmlns="http://tempuri.org/">edrewr</ProjectName>
> <ClientID xmlns="http://tempuri.org/">1</ClientID>
> <ProjectID xmlns="http://tempuri.org/">2</ProjectID>
> <AssessmentStatusID xsi:nil="true" xmlns="http://tempuri.org/" />
> <ExpectedStartDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedStartDate>
> <ExpectedEndDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedEndDate>
> <FacilityID xmlns="http://tempuri.org/">0</FacilityID>
> </BLL_Assessment>
> - <BLL_Assessment>
> <AssessmentID xmlns="http://tempuri.org/">3</AssessmentID>
> <ProjectName xmlns="http://tempuri.org/">new ass</ProjectName>
> <ClientID xmlns="http://tempuri.org/">1</ClientID>
> <ProjectID xmlns="http://tempuri.org/">3</ProjectID>
> <AssessmentStatusID xsi:nil="true" xmlns="http://tempuri.org/" />
> <ExpectedStartDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedStartDate>
> <ExpectedEndDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedEndDate>
> <FacilityID xmlns="http://tempuri.org/">0</FacilityID>
> </BLL_Assessment>
> - <BLL_Assessment>
> <AssessmentID xmlns="http://tempuri.org/">6</AssessmentID>
> <ProjectName xmlns="http://tempuri.org/">Protik Assesment</ProjectName>
> <ClientID xmlns="http://tempuri.org/">1</ClientID>
> <ProjectID xmlns="http://tempuri.org/">6</ProjectID>
> <AssessmentStatusID xsi:nil="true" xmlns="http://tempuri.org/" />
> <ExpectedStartDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedStartDate>
> <ExpectedEndDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedEndDate>
> <FacilityID xmlns="http://tempuri.org/">0</FacilityID>
> </BLL_Assessment>
> - <BLL_Assessment>
> <AssessmentID xmlns="http://tempuri.org/">4</AssessmentID>
> <ProjectName xmlns="http://tempuri.org/">qq</ProjectName>
> <ClientID xmlns="http://tempuri.org/">1</ClientID>
> <ProjectID xmlns="http://tempuri.org/">4</ProjectID>
> <AssessmentStatusID xsi:nil="true" xmlns="http://tempuri.org/" />
> <ExpectedStartDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedStartDate>
> <ExpectedEndDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedEndDate>
> <FacilityID xmlns="http://tempuri.org/">0</FacilityID>
> </BLL_Assessment>
> - <BLL_Assessment>
> <AssessmentID xmlns="http://tempuri.org/">1</AssessmentID>
> <ProjectName xmlns="http://tempuri.org/">Quality of
> WebSites</ProjectName>
> <ClientID xmlns="http://tempuri.org/">1</ClientID>
> <ProjectID xmlns="http://tempuri.org/">1</ProjectID>
> <AssessmentStatusID xsi:nil="true" xmlns="http://tempuri.org/" />
> <ExpectedStartDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedStartDate>
> <ExpectedEndDate
> xmlns="http://tempuri.org/">0001-01-01T00:00:00</ExpectedEndDate>
> <FacilityID xmlns="http://tempuri.org/">0</FacilityID>
> </BLL_Assessment>
> </ArrayOfBLL_Assessment>
>
> All I want to do is to iterate through the nodes BLL_Assessment and insert
> the value of the attributes into database. I am trying to use LINQ to XML.
> This is the code block I have tried to develop -->
>
> public void InsertAssessments()
> {
> try
> {
> int AssessmentID;
> string ProjectName;
> int ClientID;
> int ProjectID;
> string AssessmentStatusID;
> string ExpectedStartDate;
> string ExpectedEndDate;
> int FacilityID;
> var result=from item in XDocument.Load
> ("Assessments.xml").Descendants
> ("BLL_Assessments")
> select new
> {
> AssessmentID=item.Element (XNamespace.Get
> ("http://tempuri.org/")+"AssessmentID").Value,
> ProjectName =item.Element (XNamespace.Get
> ("http://tempuri.org/")+"ProjectName").Value,
> ClientID=item.Element (XNamespace.Get
> ("http://tempuri.org/")+"ClientID").Value,
> ProjectID=item.Element (XNamespace.Get
> ("http://tempuri.org/")+"ProjectID").Value,
> AssessmentStatusID=item.Element (XNamespace.Get
> ("http://tempuri.org/")+"AssessmentStatusID").Value,
> ExpectedStartDate=item.Element (XNamespace.Get
> ("http://tempuri.org/")+"ExpectedStartDate").Value,
> ExpectedEndDate=item.Element (XNamespace.Get
> ("http://tempuri.org/")+"ExpectedEndDate").Value,
> FacilityID=item.Element (XNamespace.Get
> ("http://tempuri.org/")+"FacilityID").Value
>
>
> } ;
> string[] strass=new string[]{"CREATE TABLE IF NOT EXISTS
> ClientAssessments('AssessmentOfflineID' integer primary key autoincrement,
> 'ProjectName' text, 'ClientID' integer, 'ProjectID' integer,
> 'AssessmentStatusID' text, 'ExpectedStartDate' text, 'ExpectedEndDate'
> text,
> 'FacilityID' integer)",
> String.Format ("insert into ClientAssessment(AssessmentID,
> ProjectName,
> ClientID, ProjectID, AssessmentStatusID, ExpectedStartDate,
> ExpectedEndDate,
> FacilityID) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}',
> '{7}')",
> AssessmentID, ProjectName, ClientID, ProjectID, AssessmentStatusID,
> ExpectedStartDate, ExpectedEndDate, FacilityID) <------- this line shows
> the
> 8 errors for the 8 variables
> //database codes for insertion of data
> };
>
> }
> catch(Exception exp)
> {
>
> }
> }
>
> But I am getting 8 errors each for the variables in the insert statement :
> Use of uninitialized local variable VariableName. Can you please direct me
> as to how I should restructure my code, especially the scopes {}, so that I
> don't get this error? This is very crucial for me. Look forward to
> receiving
> some active help on this.
>
> Any kind of assistance will be massively appreciated.
> Thanks in advance.
>
> --
> View this message in context:
> http://monotouch.2284126.n4.nabble.com/MonoTouch-with-Sqlite-Critical-Scenario-Help-Needed-tp4655574p4655668.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch