123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- using Microsoft.AspNetCore.Mvc;
- using System.Reflection.Emit;
- using System.Xml;
- using System.Xml.Linq;
- namespace AddressPaser.Controllers
- {
- [Route("api/[controller]/[action]")]
- [ApiController]
- public class PatentGetterController : ControllerBase
- {
- [HttpGet(Name = "GetPatentbyAppNo")]
- public List<string> GetPatentbyAppNo(string appNo)
- {
- IPRS.xiaoshi.sz.com.IPRSSearcher searcher = new IPRS.xiaoshi.sz.com.IPRSSearcher();
- string retXml = searcher.GetPatentFullTxtInfo(appNo);
-
- List<string> technicalFieldTexts = new List<string>();
- XmlDocument xmlDoc = new XmlDocument();
- xmlDoc.LoadXml(retXml);
- XmlNamespaceManager nsManager = new XmlNamespaceManager(xmlDoc.NameTable);
- nsManager.AddNamespace("business", "http://www.sipo.gov.cn/XMLSchema/business");
- nsManager.AddNamespace("base", "http://www.sipo.gov.cn/XMLSchema/base");
- // XPath to find all <p> tags within <technical-field>
- XmlNodeList TNodes = xmlDoc.SelectNodes("//cn-patent-document/application-body/description/technical-field/p");
-
- if (TNodes != null)
- {
- if (TNodes.Count != 0)
- {
- foreach (XmlNode pNode in TNodes)
- {
- // Extract the text content of each <p> tag
- technicalFieldTexts.Add(pNode.InnerText.Trim());
- }
- }
- else
- {
- // 选择所有 business:Description 下的 base:Paragraphs 节点
- XmlNodeList paragraphs = xmlDoc.DocumentElement.SelectNodes("//business:Description/base:Paragraphs",
- nsManager
- );
- // 遍历节点提取内容
- foreach (XmlNode para in paragraphs)
- {
- technicalFieldTexts.Add(para.InnerText);
- }
- }
- }
-
- // XPath to find all <p> tags within <technical-field>
- XmlNodeList BNodes = xmlDoc.SelectNodes("//cn-patent-document/application-body/description/background-art/p");
- if (TNodes != null)
- {
- foreach (XmlNode pNode in BNodes)
- {
- // Extract the text content of each <p> tag
- technicalFieldTexts.Add(pNode.InnerText.Trim());
- }
- }
- // XPath to find all <p> tags within <technical-field>
- XmlNodeList DNodes = xmlDoc.SelectNodes("//cn-patent-document/application-body/description/disclosure/p");
- if (TNodes != null)
- {
- foreach (XmlNode pNode in DNodes)
- {
- // Extract the text content of each <p> tag
- technicalFieldTexts.Add(pNode.InnerText.Trim());
- }
- }
- // XPath to find all <p> tags within <technical-field>
- XmlNodeList MNodes = xmlDoc.SelectNodes("//cn-patent-document/application-body/description/mode-for-invention/p");
- if (TNodes != null)
- {
- foreach (XmlNode pNode in MNodes)
- {
- // Extract the text content of each <p> tag
- technicalFieldTexts.Add(pNode.InnerText.Trim());
- }
- }
- if(technicalFieldTexts.Count == 0)
- {
- // XPath to find all <p> tags within <technical-field>
- XmlNodeList desNodes = xmlDoc.SelectNodes("//cn-patent-document/application-body/description/p");
- if (TNodes != null)
- {
- foreach (XmlNode pNode in desNodes)
- {
- // Extract the text content of each <p> tag
- technicalFieldTexts.Add(pNode.InnerText.Trim());
- }
- }
- }
- return technicalFieldTexts;
- }
- }
- }
|