Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / March 2008

Tip: Looking for answers? Try searching our database.

XML atribute value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Benn H.J. Molund - 11 Mar 2008 16:01 GMT
Asking for XML atribute value
HI,

I m lost when I wanna ask for attributes value’s
XML file:

hi,

my xml file is:

<?xml version="1.0" encoding="ISO-8859-1"?>
<Message xmlns="http://www.kith.no/xmlstds/henvisning/2005-07-08"
xmlns:xsd="http://www.w3.org/2001/XMLSchema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kith.no/xmlstds/henvisning/2005-07-08
Henvisning-v1.0.xsd">
    <Type V="H"/>
    <MsgVersion>v1.0 2005-07-08</MsgVersion>
    <MIGversion>v1.0 2005-07-08</MIGversion>
    <GenDate V="2005-07-06T11:30:47"/>
    <MsgId>Referansenummer123456</MsgId>
    <ServReq>
        <!--  Opplysninger om henvisningen -->
        <ServType V="N"/>
        <IssueDate V="2002-09-14"/>
        <MsgDescr V="1" DN="Utredning"/>
        <Id>FY020725A</Id>
        <Patient>
            <!--  Opplysninger om pasient -->
            <Sex V="1"/>
            <DateOfBirth V="1940-09-16"/>
            <Name>Syk, Petter</Name>
            <OffId>16094034523</OffId>
            <TypeOffId V="FNR"/>
            <!-- Kliniske opplysninger - dekker Utredningsresultater, tidligere
sykdommer, Cave og legemidler -->
            <!-- Utredningsresultater -->
            <InfItem>
                <Observation>
...
..

XElement xmlHenvisning = XElement.Load(@"Henv-eks1-v1.0.xml");

XNamespace nsHenvisning = xmlHenvisning.GetDefaultNamespace();
     
XElement patient  = xmlHenvisning.Element(nsHenvisning +                    
        "ServReq").Element(nsHenvisning + "Patient");

           foreach(XAttribute a in patient.Attributes())
           {
               Console.WriteLine(a.Value);
           }
Returns null, why?

Signature

Projectleader / .NET system devloper

Martin Honnen - 11 Mar 2008 16:10 GMT
> <Message xmlns="http://www.kith.no/xmlstds/henvisning/2005-07-08"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema.xsd"
[quoted text clipped - 13 lines]
>         <Id>FY020725A</Id>
>         <Patient>
                ^^^^^^^^^
That Patient element does not have any attributes, attributes would look
like this
                <Patient att1="value 1" att2="value 2">

Signature

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.