Reputation: 23
I am working with a windows phone8 application. I have a file stored at a particular location in device and i want to open it with XElement. If i give path to that file it says uri should be relative and see webclient for more details. I know that it cant take xmlReader cause its not availabe in windows phone so that leaves me with two options to open a file with XElement which are String uri which windows phone libraries treat as a url and TextReader.
Can some one please give me an idea how to load my file in XElement directly for reading and writing purpose. Please help me out on this. or Any other way to handle my xml files.
Regards
Upvotes: 0
Views: 393
Reputation: 1502036
The first approach I'd suggest is opening the path as a stream, and then use XDocument.Load(Stream)
. (There's a similar method for XElement
, but I typically use XDocument
when I'm loading a whole document, to make it clear that that's what I'm doing.)
That may cause issues if the document has relative DTD links or something similar, but in the vast majority of cases it will work.
Likewise you can save to a stream too.
Upvotes: 2