Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get all attributes #185

Closed
michaelrsweet opened this issue Feb 9, 2017 · 5 comments
Closed

get all attributes #185

michaelrsweet opened this issue Feb 9, 2017 · 5 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@michaelrsweet
Copy link
Owner

michaelrsweet commented Feb 9, 2017

Version: -feature
Original reporter: Loo

Hi,

as an idea (because I needed that) perhaps this is useful to other people too.
I wanted to have all attributes to an element w/o name reference. I fetch the count via mxmlElementGetAttrCount (see below) and handover a pointer array with 2countsizeof(char *) to mxmlElementGetAllAttr which fills in the references to the name/value pairs.
This was added to mxml_attr.c for version 2.10

Greetings
Otto


void mxmlElementGetAllAttr(mxml_node_t *node, char **pa)
{
  int		i;			/* Looping var */
  mxml_attr_t	*attr;			/* New attribute */

  if (!node || node->type != MXML_ELEMENT)
    return;

  for (i = node->value.element.num_attrs, attr = node->value.element.attrs;
       i > 0;
       i --, attr ++)
  {
	*pa++ = attr->name;
	*pa++ = attr->value;
  }
}

int mxmlElementGetAttrCount(mxml_node_t *node)
{
  if (!node || node->type != MXML_ELEMENT)
    return (-1);

  return (node->value.element.num_attrs);
}
@michaelrsweet
Copy link
Owner Author

Original reporter: Loo

Somehow this landed under HTMLDOC. Ofcourse this belongs to MXML ...

@michaelrsweet michaelrsweet added the bug Something isn't working label Mar 3, 2017
@michaelrsweet michaelrsweet added this to the Future milestone Mar 3, 2017
@michaelrsweet michaelrsweet added enhancement New feature or request and removed bug Something isn't working labels Mar 9, 2017
@michaelrsweet
Copy link
Owner Author

Probably better to add an API for getting an attribute name by index, so that you can grab things one at a time.

@michaelrsweet michaelrsweet self-assigned this Mar 20, 2017
@michaelrsweet michaelrsweet modified the milestones: Stable, Future Mar 20, 2017
@loo66
Copy link

loo66 commented Apr 18, 2017

take care ... it seems when moving the article some '*' got lost ...

@michaelrsweet
Copy link
Owner Author

Fixed...

@michaelrsweet
Copy link
Owner Author

[master 48c3c62] Add mxmlElementAttrGetByIndex and mxmlElementAttrGetCount (Issue #185)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants