1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tom JacksonPosted Aug 28, 2008, 11:20 AM
I'm trying to get the same info, but I'm thinking it shouldn't be on an "EndElement" basis, if you know the tag name in the XML you are trying to get the value of. This is what I was thinking - call a function to parse your XML file using the URL of the XML file and the parameter of what you want to bring back. Something like this:
static string getXml(string parameter, string strXmlFileUrl){
string xmlFilename = Server.MapPath(strXmlFileUrl); XmlTextReader reader = new XmlTextReader(xmlFilename);reader.WhitespaceHandling =
WhitespaceHandling.None; while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: if (reader.Name == parameter) { return reader.GetAttribute(parameter);}
break; case XmlNodeType.Text: if (reader.Name == parameter) { return reader.Value;}
break;}
}
reader.Close();
}
I stress that that is UNTESTED code, and just my idea of how it should work...
-Tom