Signo.X
Well-known member
Hello All ,
I'm developing a vb.net programe that validates the xml files using XSD (XML Schema).
that's my .xml file:
that's my .xsd validating file:
my problem is the following, as the .xml file is inconsistent for every file, for e.g. some specific authors could have a location element or nickname element which is not specified in the .xml file simply becuase i dono if the author will always have a nick name or a location element.
how do i check if the location element(or any extinsible element) exist , and if it does how to check that there is data in the element and its not empty.
Thanks in advance.
~Signo.x
I'm developing a vb.net programe that validates the xml files using XSD (XML Schema).
that's my .xml file:
VB.NET:
[SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#800000]book[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]author[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]first-name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE][SIZE=2]Mark[/SIZE][SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]first-name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]last-name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE][SIZE=2]Twain[/SIZE][SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]last-name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]age[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE][SIZE=2]56[/SIZE][SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]age[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]author[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]book[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
that's my .xsd validating file:
VB.NET:
[SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:schema[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]xmlns:xsd[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]http://www.w3.org/2001/XMLSchema[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#ff0000] elementFormDefault[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]qualified[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:element[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]book[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:complexType[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]<[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:sequence[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:element[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]author[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:complexType[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:sequence[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]> [/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:element[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]first-name[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#ff0000]type[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]xsd:string[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff] />[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:element[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]last-name[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#ff0000]type[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]xsd:string[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff] />[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff] <[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:element[/COLOR][/SIZE][SIZE=2][COLOR=#ff0000]name[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]age[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#ff0000]type[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]=[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff]xsd:positiveInteger[/COLOR][/SIZE][SIZE=2]"[/SIZE][SIZE=2][COLOR=#0000ff] />[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:sequence[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:complexType[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:element[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]<!--[/COLOR][/SIZE][SIZE=2][COLOR=#008000] end of author element[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]-->[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:sequence[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:complexType[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:element[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]<!--[/COLOR][/SIZE][SIZE=2][COLOR=#008000] end of book element[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]-->[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]</[/COLOR][/SIZE][SIZE=2][COLOR=#800000]xsd:schema[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]>[/COLOR][/SIZE]
my problem is the following, as the .xml file is inconsistent for every file, for e.g. some specific authors could have a location element or nickname element which is not specified in the .xml file simply becuase i dono if the author will always have a nick name or a location element.
how do i check if the location element(or any extinsible element) exist , and if it does how to check that there is data in the element and its not empty.
Thanks in advance.
~Signo.x