-1
다른 스키마 XSD에 따라 XML 파일을 다시 작성할 수 있습니까? C#? 다른 스키마 기반 XML 파일에 XML 파일을 사용하여 C#
이
는 XML 파일입니다이 변경된 노드 이름
하지만 새 스키마 같은 모든 것새 XML을 가져 오는 방법 새 XSD를 기반으로하는 오래된 하나는 C#을 사용합니까?
다른 스키마 XSD에 따라 XML 파일을 다시 작성할 수 있습니까? C#? 다른 스키마 기반 XML 파일에 XML 파일을 사용하여 C#
이
는 XML 파일입니다이 변경된 노드 이름
하지만 새 스키마 같은 모든 것새 XML을 가져 오는 방법 새 XSD를 기반으로하는 오래된 하나는 C#을 사용합니까?
사용하여 XML LINQ :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication13
{
class Program
{
const string FILENAME = @"c:\temp\test.xml";
static void Main(string[] args)
{
XDocument doc = XDocument.Load(FILENAME);
List<XElement> shipTo = doc.Descendants("shipto").ToList();
foreach (XElement ship in shipTo)
{
ship.Element("name").ReplaceWith(new XElement("FullName", (string)ship.Element("name")));
ship.Element("address").ReplaceWith(new XElement("FirstAddress", (string)ship.Element("address")));
ship.Element("city").ReplaceWith(new XElement("homeTown", (string)ship.Element("city")));
ship.Element("country").ReplaceWith(new XElement("HomeLand", (string)ship.Element("country")));
}
}
}
}