Connecting Tech Pros Worldwide Forums | Help | Site Map

read nodelist from xml in asp.net problem

Member
 
Join Date: Nov 2007
Posts: 52
#1: Jan 8 '09
well i have an xml file :

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="ISO-8859-7"?>
  2. <RealEstate xmlns="http://bankofgreece.gr/dom/real_estate/v1">
  3.   <Header>
  4.     <SenderId>999</SenderId>
  5.     <SenderName>Eurobank</SenderName>
  6.     <ReferencePeriod>2008-1</ReferencePeriod>
  7.   </Header>
  8.   <Data>
  9.     <Property>
  10.       <PropertyId>R2_1342_19509</PropertyId>
  11.       <PropertyType>1</PropertyType>
  12.       <PropertyLocation>
  13.         <Street>ΤΡΑΠΕΖΟΥΝΤΟΣ 12-0</Street>
  14.         <PostCode>14565</PostCode>
  15.         <Municipality>kazaman</Municipality>
  16.         <District>ΑΝΑΤΟΛΙΚΗΣ ΑΤΤΙΚΗΣ</District>
  17.       </PropertyLocation>
  18.       <DateOfEvaluation>2008-01-21</DateOfEvaluation>
  19.       <PropertyAge>
  20.         <YearOfPermit>
  21.         </YearOfPermit>
  22.         <YearOfCompletion>0</YearOfCompletion>
  23.       </PropertyAge>
  24.       <FloorNumber>2</FloorNumber>
  25.       <PropertySpaceInformation>
  26.         <LandArea>
  27.         </LandArea>
  28.         <MainSpaceArea>470,00000</MainSpaceArea>
  29.         <AuxiliarySpaceArea>40,00000</AuxiliarySpaceArea>
  30.       </PropertySpaceInformation>
  31.       <StoreRoomsAndParkingSpaces>
  32.         <NumberOfStoreRooms1>0</NumberOfStoreRooms1>
  33.         <TotalAreaOfStoreRooms1>0,00000</TotalAreaOfStoreRooms1>
  34.         <NumberOfParkingSpaces1>0</NumberOfParkingSpaces1>
  35.         <TotalAreaOfParkingSpaces1>0,00000</TotalAreaOfParkingSpaces1>
  36.         <NumberOfStoreRooms2>0</NumberOfStoreRooms2>
  37.         <NumberOfParkingSpaces2>0</NumberOfParkingSpaces2>
  38.       </StoreRoomsAndParkingSpaces>
  39.       <OtherPropertyFeatures>
  40.         <ExcellentQualityOfConstruction>0</ExcellentQualityOfConstruction>
  41.         <ExcellentPositionViewEnviroment>
  42.         </ExcellentPositionViewEnviroment>
  43.         <RecentlyRenovated>0</RecentlyRenovated>
  44.         <DepreciatedDistrict>
  45.         </DepreciatedDistrict>
  46.       </OtherPropertyFeatures>
  47.       <PropertyValueInformation>
  48.         <LandAssessedValue>0,00000000000</LandAssessedValue>
  49.         <PropertyTotalAssesedValue>1280000,0000</PropertyTotalAssesedValue>
  50.         <StoreRoomsAssesedValue>0,0000</StoreRoomsAssesedValue>
  51.         <ParkingSpacesAssesedValue>0,0000</ParkingSpacesAssesedValue>
  52.         <TotalConstructionCost>0,00000000000</TotalConstructionCost>
  53.       </PropertyValueInformation>
  54.       <TotalAdministrativeValue />
  55.       <LoanInformation>
  56.         <LoanType />
  57.         <DateOfFirstDisbursement />
  58.         <ApprovedLoanAmount />
  59.         <TotalAmountDisbursed />
  60.         <MortgagePrenotationValue />
  61.       </LoanInformation>
  62.     </Property>
  63. <Data>
  64. <RealEstate>
  65.  

well i have a problem when i try to read a nodelist <Data> because of <RealEstate xmlns="http://bankofgreece.gr/dom/real_estate/v1">
but when i it is like <RealEstate > it works fine i can read all nodelist as expected . how can i solve this little problem any idea????

Moderator
 
Join Date: Mar 2006
Posts: 1,103
#2: Jan 14 '09

re: read nodelist from xml in asp.net problem


Namespace problem. Are you using SelectNodes? eg, what is the exact problem you are having?

Eg, in .NET you would need to use a namespace manager.
http://msdn.microsoft.com/en-us/library/4bektfx9.aspx
Member
 
Join Date: Nov 2007
Posts: 52
#3: Jan 16 '09

re: read nodelist from xml in asp.net problem


yes i am using select nodes , ok i coded it with namespacemanager as above:


[SIZE=2]xmldoc.LoadXml(theXMLString)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] nsmanager [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] XmlNamespaceManager(xmldoc.NameTable)
nsmanager.AddNamespace([/SIZE][SIZE=2][COLOR=#a31515]"dt"[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#a31515]"http://bankofgreece.gr/dom/real_estate/v1"[/COLOR][/SIZE][SIZE=2])
list = xmldoc.SelectNodes([/SIZE][SIZE=2][COLOR=#a31515]"//dt:Data"[/COLOR][/SIZE][SIZE=2], nsmanager)[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][/SIZE]
[SIZE=2]but my question how can i do with some other way , because if the namespace is different of a uploaded XML document this code will not work.. my question is if there is any programaticaly way to avoid any namespace of uploaded XML document and select nodes without any problem???
[/SIZE]
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#4: Jan 16 '09

re: read nodelist from xml in asp.net problem


The xpath becomes something like
"*[local-name() = 'RealEstate']/*[local-name()='Header']"

Why would your namespace differ? Is there no defined schema for your input?
Reply