EDN Admin
Well-known member
Hi
I am attempting to query an xml file witch has an namespace and am not sure how to go about this! can anyone point me in the right direction.
code:<span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small Dim<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
doc <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small As<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small XDocument<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
= <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small XDocument<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small .Load(XMLDOCFILEPATH)<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small Dim<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
qList = <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small From<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
xe <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small In<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
doc.XPathSelectElements(<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "//Tasks"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small )
_<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small Select
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small New<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small With<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
{ _<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
.TaskId = xe.Attribute(
<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "TaskId"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ).Value,
_<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "Question"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ).Value,
_<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "Result"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ).Value,
_<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "Comment"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ).Value
_ <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small Me<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small .DataGridView1.DataSource
= qList.ToList
.Question = xe.Attribute(
.Result = xe.Element(
.Comment = xe.Element(
}
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small XML:
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small <DriverEvent xmlns=" http://mycomp.co.uk/Sexton.xsd/v2 http://mycomp.co.uk/Sexton.xsd/v2 <br/>
<CompanyShortName>TRO</CompanyShortName> <br/>
<EngineerId>1004</EngineerId> <br/>
<TimeStamp>2010-11-12T17:21:10</TimeStamp> <br/>
<EventType>Logon</EventType> <br/>
- <Placeholder><br/>
- <ScheduledChecks><br/>
<StartDateTime>2010-11-12T17:21:10</StartDateTime> <br/>
<EndDateTime>2010-11-12T17:23:58</EndDateTime> <br/>
- <Tasks><br/>
- <Task><br/>
<Question>Confirm vehicle registration</Question> <br/>
<Result>R45 OTR</Result> <br/>
<TaskId>01</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are there any fuel or oil leaks</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>02</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>What is the battery condition</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>03</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>what are the condition of the tyres and wheels</Question>
<br/>
<Result>OK</Result> <br/>
<TaskId>04</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Is the steering OK</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>05</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the mirrors OK</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>06</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the lights OK</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>07</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Is the oil level ok</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>08</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the reflectors in good condition</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>09</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the indicators in good condition</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>10</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the wipers working and the blades in good condition.</Question>
<br/>
<Result>OK</Result> <br/>
<TaskId>11</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the washers ok</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>12</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Does the horn work</Question> <br/>
<Result>YES</Result> <br/>
<TaskId>13</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the water levels OK.</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>14</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the brakes in good order.</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>15</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the brake hoses in good condition.</Question> <br/>
<Result>N/A</Result> <br/>
<TaskId>16</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the electrical connectors in good order.</Question>
<br/>
<Result>N/A</Result> <br/>
<TaskId>17</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Coupling Security</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>18</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Driver Signature</Question> <br/>
<Result>Signed By: JSMITH</Result> <br/>
<TaskId>19</TaskId> <br/>
<Comment /> <br/>
<Image type="rle4 </Image> <br/>
</Task><br/>
- <Task><br/>
<Question>Are you at work</Question> <br/>
<Result>NO</Result> <br/>
<TaskId>0</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Do you have a Company vehicle with you</Question> <br/>
<Result>YES</Result> <br/>
<TaskId>1</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are you at home and available for work</Question> <br/>
<Result>YES</Result> <br/>
<TaskId>3</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
</Tasks><br/>
</ScheduledChecks><br/>
</Placeholder><br/>
</DriverEvent>
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<div style="text-indent:-2em http://social.msdn.microsoft.com/Forums/en/# <span style="font-family:Courier New; color:#ff0000 -
<
Joe
View the full article
I am attempting to query an xml file witch has an namespace and am not sure how to go about this! can anyone point me in the right direction.
code:<span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small Dim<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
doc <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small As<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small XDocument<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
= <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small XDocument<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small .Load(XMLDOCFILEPATH)<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small Dim<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
qList = <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small From<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
xe <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small In<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
doc.XPathSelectElements(<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "//Tasks"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small )
_<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small Select
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small New<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small With<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
{ _<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
.TaskId = xe.Attribute(
<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "TaskId"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ).Value,
_<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "Question"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ).Value,
_<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "Result"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ).Value,
_<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small <span style="font-family:Consolas; color:#a31515; font-size:x-small "Comment"<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small ).Value
_ <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small <span style="font-family:Consolas; color:#0000ff; font-size:x-small Me<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small .DataGridView1.DataSource
= qList.ToList
.Question = xe.Attribute(
.Result = xe.Element(
.Comment = xe.Element(
}
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small XML:
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small <DriverEvent xmlns=" http://mycomp.co.uk/Sexton.xsd/v2 http://mycomp.co.uk/Sexton.xsd/v2 <br/>
<CompanyShortName>TRO</CompanyShortName> <br/>
<EngineerId>1004</EngineerId> <br/>
<TimeStamp>2010-11-12T17:21:10</TimeStamp> <br/>
<EventType>Logon</EventType> <br/>
- <Placeholder><br/>
- <ScheduledChecks><br/>
<StartDateTime>2010-11-12T17:21:10</StartDateTime> <br/>
<EndDateTime>2010-11-12T17:23:58</EndDateTime> <br/>
- <Tasks><br/>
- <Task><br/>
<Question>Confirm vehicle registration</Question> <br/>
<Result>R45 OTR</Result> <br/>
<TaskId>01</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are there any fuel or oil leaks</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>02</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>What is the battery condition</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>03</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>what are the condition of the tyres and wheels</Question>
<br/>
<Result>OK</Result> <br/>
<TaskId>04</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Is the steering OK</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>05</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the mirrors OK</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>06</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the lights OK</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>07</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Is the oil level ok</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>08</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the reflectors in good condition</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>09</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the indicators in good condition</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>10</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the wipers working and the blades in good condition.</Question>
<br/>
<Result>OK</Result> <br/>
<TaskId>11</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the washers ok</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>12</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Does the horn work</Question> <br/>
<Result>YES</Result> <br/>
<TaskId>13</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the water levels OK.</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>14</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the brakes in good order.</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>15</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the brake hoses in good condition.</Question> <br/>
<Result>N/A</Result> <br/>
<TaskId>16</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are the electrical connectors in good order.</Question>
<br/>
<Result>N/A</Result> <br/>
<TaskId>17</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Coupling Security</Question> <br/>
<Result>OK</Result> <br/>
<TaskId>18</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Driver Signature</Question> <br/>
<Result>Signed By: JSMITH</Result> <br/>
<TaskId>19</TaskId> <br/>
<Comment /> <br/>
<Image type="rle4 </Image> <br/>
</Task><br/>
- <Task><br/>
<Question>Are you at work</Question> <br/>
<Result>NO</Result> <br/>
<TaskId>0</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Do you have a Company vehicle with you</Question> <br/>
<Result>YES</Result> <br/>
<TaskId>1</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
- <Task><br/>
<Question>Are you at home and available for work</Question> <br/>
<Result>YES</Result> <br/>
<TaskId>3</TaskId> <br/>
<Comment /> <br/>
</Task><br/>
</Tasks><br/>
</ScheduledChecks><br/>
</Placeholder><br/>
</DriverEvent>
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<div style="text-indent:-2em http://social.msdn.microsoft.com/Forums/en/# <span style="font-family:Courier New; color:#ff0000 -
<
Joe
View the full article