Click or drag to resize

FileLoaderLoad Method (IGraph, String)

Loads the contents of the given File into a Graph providing the RDF format can be determined.

Namespace:  VDS.RDF.Parsing
Assembly:  dotNetRDF (in dotNetRDF.dll) Version:
public static void Load(
	IGraph g,
	string filename


Type: VDS.RDFIGraph
Graph to load into.
Type: SystemString
File to load from.

The FileLoader first attempts to select a RDF Parser by examining the file extension to select the most likely MIME type for the file. This assumes that the file extension corresponds to one of the recognized file extensions for a RDF format the library supports. If this suceeds then a parser is chosen and will be used to attempt to parse the input.

Should this fail then the contents of the file will be read into a String, the StringParser is then used to attempt to parse it. The StringParser uses some simple rules to guess which format the input is likely to be and chooses a parser based on it's guess.

Note: FileLoader will assign the Graph a file URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.

If a File URI is assigned it will always be an absolute URI for the file.

See Also