Reading XML through a web service

Good morning guys, I know there are already several scattered XML reading posts. But I can not adapt the codes to the situation I need.

My goal is to read the following XML


  
    LANIFICIO SAO FRANCISCO LTDA
    61.187.845/0001-22
    490382049
    2019-08-14
    Retingimento
    78 789 797/9797-99
    Div. Nfe/Rom.
    
      7897987
      1050
      3 | LAVAR E RAMAR
      018179
      99.99
      0
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
    
    
      7897987
      1050
      3 | LAVAR E RAMAR
      018179
      99.99
      0
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
    
    
      7897987
      1050
      3 | LAVAR E RAMAR
      018179
      99.99
      0
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
    
  
  
    LANIFICIO SAO FRANCISCO LTDA
    61.187.845/0001-22
    490382049
    2019-08-14
    Retingimento
    78 789 797/9797-99
    Div. Nfe/Rom.
    
      7897987
      1050
      3 | LAVAR E RAMAR
      018179
      99.99
      0
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
    
    
      7897987
      1050
      3 | LAVAR E RAMAR
      018179
      99.99
      0
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
    
    
      7897987
      1050
      3 | LAVAR E RAMAR
      018179
      99.99
      0
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
    
  
  
    LANIFICIO SAO FRANCISCO LTDA
    61.187.845/0001-22
    490382049
    2019-08-14
    Retingimento
    78 789 797/9797-99
    Div. Nfe/Rom.
    
      7897987
      1050
      3 | LAVAR E RAMAR
      018179
      99.99
      0
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
    
    
      7897987
      1050
      3 | LAVAR E RAMAR
      018179
      99.99
      0
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
    
    
      7897987
      1050
      3 | LAVAR E RAMAR
      018179
      99.99
      0
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
      
        1231231123
        12.400
        0.000
        
      
    
  

The goal is to read and save the data in the database for validation (example: maximum weight, repeated batches, etc.).

I tried a few dozen different codes, both with XmlTextReader xmlReader = new XmlTextReader(caminhoArquivo); how much XmlDocument doc = new XmlDocument();

But I currently have the following:

(WebMethod(Description = "Lendo um Xml de Romaneio"))
    public xml_lote LerXml(/*(XmlElementAttribute(IsNullable = true)) string Xml,*/)
    {
        List lotes = new List();
        List romaneios = new List();
        List pecas = new List();
        XmlDocument oXML = new XmlDocument();
        XmlNodeList oNoLista = default(XmlNodeList);
        //monta o caminho do arquivo na raiz do projeto
        caminhoArquivo = Directory.GetParent(Directory.GetParent(caminhoArquivo).FullName).FullName;
        caminhoArquivo += @"filmes.xml";
        XmlTextReader xmlReader = new XmlTextReader(caminhoArquivo);
        oXML.Load(caminhoArquivo);
        Lote lote = new Lote();
        Romaneioo romaneio = new Romaneioo();
        Peca peca = new Peca();
        while (xmlReader.Read())
        {
            switch (xmlReader.NodeType)
            {
                case XmlNodeType.Element:
                    lote.id_lote += Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    lote.nome += xmlReader.Value;
                    lote.nr_nota_fiscal += xmlReader.Value;
                    lote.dc_tipo += xmlReader.Value;
                    romaneio.id_romaneio = Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    romaneio.nr_cod_produto = xmlReader.Value;
                    peca.id_peca = Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    peca.nr_peca = xmlReader.Value;
                    lotes.Add(lote);
                    romaneios.Add(romaneio);
                    pecas.Add(peca);
                    break;
                case XmlNodeType.Text:
                    lote.id_lote += Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    lote.nome += xmlReader.Value;
                    lote.nr_nota_fiscal += xmlReader.Value;
                    lote.dc_tipo += xmlReader.Value;
                    romaneio.id_romaneio = Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    romaneio.id_romaneio = Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    peca.id_peca = Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    lotes.Add(lote);
                    romaneios.Add(romaneio);
                    pecas.Add(peca);
                    break;
                case XmlNodeType.EndElement:
                    lote.id_lote += Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    lote.nome += xmlReader.Value;
                    lote.nr_nota_fiscal += xmlReader.Value;
                    lote.dc_tipo += xmlReader.Value;
                    romaneio.id_romaneio = Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    peca.id_peca = Convert.ToInt32(xmlReader.GetAttribute("ID"));
                    lotes.Add(lote);
                    romaneios.Add(romaneio);
                    pecas.Add(peca);
                    break;
            }

        }            
        romaneio.pecas = pecas;

        xml_lote dadosXML = new xml_lote(lotes);
        return dadosXML;
    }

But I can not achieve my goal of storing what I need in lists or variables.
PS: I already have the function that sends the data to the database, the parameters come from this XML read function.
PS2: I have already created the necessary variables:

 public class Lote
    {
        (XmlAttribute("ativo"))
        public bool ativo = true;

        (XmlElement("ID_Lote"))
        public int id_lote { get; set; }

        (XmlElement("Nome"))
        public string nome { get; set; }

        (XmlElement("NR_Nota_Fiscal"))
        public string nr_nota_fiscal { get; set; }

        (XmlElement("DC_Tipo"))
        public string dc_tipo { get; set; }

        (XmlElement("Romaneios"))
        public List romaneios { get; set; }

        //(XmlElement("DT_Emissao"))  
        //public DateTime DT_Emissao { get; set; } nao aceita por ser um time date time
    }

    public class Romaneioo
    {
        (XmlAttribute("ativo"))
        public bool ativo = true;

        (XmlElement("ID_Romaneio"))
        public int id_romaneio { get; set; }

        (XmlElement("NR_Romaneio"))
        public string nr_romaneio { get; set; }

        (XmlElement("DC_Artigo"))
        public string dc_artigo { get; set; }

        (XmlElement("DC_Cor"))
        public string dc_cor { get; set; }

        (XmlElement("OP_Tipo"))
        public int op_tipo { get; set; }

        (XmlElement("NR_Cod_Produto"))
        public string nr_cod_produto { get; set; }

        (XmlElement("NR_Largura"))
        public decimal nr_largura { get; set; }

        (XmlElement("NR_Gramatura"))
        public int nr_gramatura { get; set; }

        (XmlElement("DC_Obs"))
        public string dc_obs { get; set; }

        (XmlElement("Pecas"))
        public List pecas { get; set; }
    }

    public class Peca
    {
        (XmlAttribute("ativo"))
        public bool ativo = true;

        (XmlElement("ID_Peca"))
        public int id_peca { get; set; }

        (XmlElement("NR_Peca"))
        public string nr_peca { get; set; }

        (XmlElement("NR_Peso"))

        public decimal nr_peso { get; set; }

        (XmlElement("NR_Comprimento"))
        public decimal nr_comprimento { get; set; }

        (XmlElement("TP_Maquina"))

        public string tp_maquina { get; set; }
    }

t sql – Empty strings, NULLs, and For XML Path

I have no control over the source table.
There is a mixture of zeroes and empty strings.
What I need is that all users in a line and with a semicolon delineate a list of all their permissions. I can remove the leading semicolon in the later code, but the double semicolon and the empty string semicolon kill me.

My table:

EMPLOYEEID | USERNAME | ISPRIMARY | ENTITLEMENTS 
123456     | BSmith   |   Y       | ac-les-all-full;ac-haw-all-full
123456     | BSmith   |   N       | ac-sco-all-full
987654     | ZJones   |   N       | NULL
987654     | ZJones   |   Y       | ac-trn-std-full Y
987654     | ZJones   |   N       | 
456789     | RTaylor  |   Y       |

I want to return:

USERNAME | ENTITLEMENTS
BSmith   | ;ac-les-all-full;ac-haw-all-full;ac-sco-all-full
ZJones   | ;ac-trn-std-full
RTaylor  | 

My current SQL:

SELECT
    USERNAME
    ,ENTITLEMENTS = (
        SELECT DISTINCT ';' + ENTITLEMENTS
        FROM (staff_user_data) STS
        WHERE STS.(EMPLOYEEID) = STP.(EMPLOYEEID)
        FOR XML PATH(''))
FROM (staff_user_data) STP
WHERE ISPRIMARY = 'Y'

What I get is

USERNAME | ENTITLEMENTS
BSmith   | ;ac-les-all-full;ac-haw-all-full;ac-sco-all-full
ZJones   | ;;ac-trn-std-full
RTaylor  | ;

magento2 – How to fix "element is not expected" on a CMS page without XML changes?

I get the following error message, but as you can see in the picture, there are neither XML updates nor content. How can I fix this?

Please correct the XML data and try again. Element # reference #: This element is not expected. One of (referenceContainer, container, update, move, head, body) is expected. line 1

Magento2 This item is not expected

xml – SharePoint HTML conversion

This is all new to me, so I may make a rookie mistake.

I'm trying to use Sharepoint Design Manager to convert an HTML site, and I'm currently using only an HTML template from Adobe.

When I try this, I get the following error message. (See the attached picture)

I think that's the code it's having problems with

Simple topic

Hope someone can help me understand what's going on here.

Thank you very much,

Matthew.

how to just install php xml and not update or touch anything

Hi,

I miss PHP Simplexml with my PHP7.0 version. I want to install it, but at the same time I do not want to mess around with the upgrade or anything else

Is there any way I can download simplexml php file and upload it into php folder will this work?

Please let me know if it is possible to install without updating anything other than PHP Simplexml. thanks

Web Development – Converting complex XML (or content tree) to HTML – How does it work (in Java)?

I have a deep object content tree, which I convert to XML using JAXB and a small self-written API.

But now I want to create a static HTML site that basically has the same content (and structure) as the XML site, but contains tables, parts that can be compressed, images, and so on.

How can I tackle this?

  • Use XSLT It seems a bit "redundant" because it depends heavily on the XML, and as the XML changes, so does the XSLT.
  • Kind of Template engine is exaggerated because I only need a static page.
  • Create HTML with a simple library like j2html Hard coding of the structure and small methods for repetitive elements.

I am currently the last option, just because it seems to be the easiest and fastest way, but I'm worried that I'll shoot myself in the foot.

XML Sitemap Best Practice for Multilingual Websites – Should I list my URLs in any language or is it sufficient to use rel = "alternate" + hreflang?

I am working on the sitemaps of a multilingual website and have doubts about the best way to refer to each language version of a page.

For a bit of background, the site points to around 20,000 places with community commentary and descriptions. The website is available in 5 languages ​​(website.com/fr; website.com/it …)

Currently, my sitemap only refers to English pages and in the sitemap on every page I have specified for any language (as well as English) as recommended by Google.

In the Google search console, about 75% of the pages with valid coverage are described as "indexed, not submitted to the sitemap", so I think the alternative link with the "hreflang" attribute is not enough to display the page for " to "Google" to index it.

Do I have to list and use the pages in all 5 languages ​​in my sitemap? at every link?