XML 파일에서 리디렉션을로드 중입니다.XML 파일로드 중
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfRedirectModel xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RedirectModel>
<Time>0001-01-01T00:00:00</Time>
<oldUrl>/301/</oldUrl>
<newUrl>/alloy-track/</newUrl>
<type>1</type>
<Id>6d278d45-aab1-4fa2-953f-f03963a29ff8</Id>
</RedirectModel>
</ArrayOfRedirectModel>
을 그리고 내가 읽은 곳 XML 코드는 다음과 같습니다 파일 :
XML 파일은 다음과 같습니다.
XmlDocument xDoc = new XmlDocument();
string mappath = HttpContext.Current.Server.MapPath("~/ClientResources/SeoCache");
xDoc.Load(mappath + "//cache.xml");
XmlNodeList xmlSelectedNodes = xDoc.SelectNodes("RedirectModel");
foreach (XmlNode node in xmlSelectedNodes)
{
하지만 "xmlSelectedNodes"는 "null"로 유지됩니다.
문자열 변수에 "oldUrl"및 "newUrl"을 사용하여 사용할 수있게하려고합니다.
누구든지 내가 뭘 잘못하고 있는지 알아?
문제는 'ArrayOfRedirectModel/RedirectModel'을 사용해야한다는 것입니다.하지만 LINQ to XML을 사용하는 것이 더 간단 할 것입니다. 그럴 수 있니? –